Skip to content

Commit

Permalink
Revert "keon#256 change strip_url_params3 to use OrderedDict to preve…
Browse files Browse the repository at this point in the history
…nt failing test on non deterministic retrieval of dict keys for query string (keon#367)" (keon#368)

This reverts commit 81e7853.
  • Loading branch information
Hai Hoang Dang authored Jun 28, 2018
1 parent 81e7853 commit a289b6b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
4 changes: 1 addition & 3 deletions algorithms/strings/strip_url_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import urllib
import urllib.parse

from collections import OrderedDict

# Here is a very non-pythonic grotesque solution
def strip_url_params1(url, params_to_strip=None):

Expand Down Expand Up @@ -39,7 +37,7 @@ def strip_url_params1(url, params_to_strip=None):
string = ''
else:
string += char
dict = OrderedDict()
dict = defaultdict(int)
# logic for checking whether we should add the string to our result
for i in key_value_string:
_token = i.split('=')
Expand Down
34 changes: 17 additions & 17 deletions tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,23 +339,23 @@ def test_roman_to_int(self):
self.assertEqual(3999, roman_to_int("MMMCMXCIX"))


class TestStripUrlParams(unittest.TestCase):
"""[summary]
Test for the file strip_urls_params.py
Arguments:
unittest {[type]} -- [description]
"""

def test_strip_url_params1(self):
self.assertEqual(strip_url_params1("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
self.assertEqual(strip_url_params1("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
def test_strip_url_params2(self):
self.assertEqual(strip_url_params2("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
self.assertEqual(strip_url_params2("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
def test_strip_url_params3(self):
self.assertEqual(strip_url_params3("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
self.assertEqual(strip_url_params3("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
# class TestStripUrlParams(unittest.TestCase):
# """[summary]
# Test for the file strip_urls_params.py

# Arguments:
# unittest {[type]} -- [description]
# """

# def test_strip_url_params1(self):
# self.assertEqual(strip_url_params1("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
# self.assertEqual(strip_url_params1("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
# def test_strip_url_params2(self):
# self.assertEqual(strip_url_params2("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
# self.assertEqual(strip_url_params2("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")
# def test_strip_url_params3(self):
# self.assertEqual(strip_url_params3("www.saadbenn.com?a=1&b=2&a=2"), "www.saadbenn.com?a=1&b=2")
# self.assertEqual(strip_url_params3("www.saadbenn.com?a=1&b=2", ['b']), "www.saadbenn.com?a=1")


class TestValidateCoordinates(unittest.TestCase):
Expand Down

0 comments on commit a289b6b

Please sign in to comment.