Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some improvements #9

Merged
merged 4 commits into from
Dec 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ dist/
*venv*/

# test
.tox/

# ide
.vscode/
.tox/
2 changes: 1 addition & 1 deletion tests/test_on_fetched_robotstxt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from protego import Protego

test_data_directory = join(dirname(abspath(__file__)), 'test_data')
robotstxts = [(f) for f in listdir(test_data_directory) if isfile(join(test_data_directory, f))]
robotstxts = [f for f in listdir(test_data_directory) if isfile(join(test_data_directory, f))]


@pytest.mark.parametrize('path_to_robotstxt', robotstxts)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_protego.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,12 +822,12 @@ def test_implicit_allow(self):
self.assertFalse(rp.can_fetch("/blahblahblah", "SomeOtherBot"))

def test_grouping_unknown_keys(self):
'''
"""
When we encounter unknown keys, we should disregard any grouping that may have
happened between user agent rules.
This is an example from the wild. `Invalid_directive` not being a valid directive,
we'll not consider the '*' and 'ia_archiver' rules together.
'''
"""
content = """
User-agent: abc
Disallow: /content/2/
Expand Down Expand Up @@ -999,7 +999,7 @@ def test_url_case_sensitivity(self):
self.assertTrue(rp.can_fetch("http://foo.bar/x/y", "FooBot"))

def test_nonterminal_dollar(self):
'''Non terminal dollar sign should be treated as an odinary character.'''
"""Non terminal dollar sign should be treated as an odinary character."""
content = ("user-agent: FooBot\n"
"disallow: /x$/abc\n"
"disallow: /y/abc$\n"
Expand All @@ -1016,7 +1016,7 @@ def test_nonterminal_dollar(self):
self.assertTrue(rp.can_fetch("http://foo.bar/yabcy/abcdef", "FooBot"))

def test_escaped_special_symbols(self):
'''Percent encoded special symbols should be treated as ordinary characters.'''
"""Percent encoded special symbols should be treated as ordinary characters."""
content = ("user-agent: FooBot\n"
"disallow: /x/abc%24\n"
"disallow: /x%2Ax/abc\n")
Expand All @@ -1029,7 +1029,7 @@ def test_escaped_special_symbols(self):
self.assertTrue(rp.can_fetch("http://foo.bar/xabcx/abc", "FooBot"))

def test_special_symbols_dual_behaviour(self):
'''Special symbols such as * and $, should also be treated as an ordinary character'''
"""Special symbols such as * and $, should also be treated as an ordinary character"""
content = ("user-agent: FooBot\n"
"disallow: /x/abc$\n"
"disallow: /x*x/abc\n")
Expand Down
1 change: 0 additions & 1 deletion tests/test_unquote.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def test_unquoting_plus(self):
result = _unquote(given)
self.assertEqual(expect, result,
"using unquote(): %r != %r" % (expect, result))
expect = given.replace('+', ' ')

def test_unquote_with_unicode(self):
# Characters in the Latin-1 range, encoded with UTF-8
Expand Down