I am trying to pass tests given in the project. And encounter a test file failed.
__________________________________________ test_persisting __________________________________________
tmpdir = local('/private/var/folders/gw/ylsybrkd7495cv7h7tqk7jg80000gn/T/pytest-of-joelzhang/pytest-0/test_persisting0')
def test_persisting(tmpdir):
"""Test saving and reading url path_items from disk"""
test = UrlPattern(
name="test",
pattern="https://host{pattern1}/something{pattern2}.php",
help_text="Test pattern",
)
test2 = UrlPattern(
name="test2", pattern="https://athing.com", help_text="Another test pattern"
)
test3 = UrlPattern(
name="test3",
pattern="https://uniqcode_Привет.com",
help_text="Another test pattern",
)
test4 = UrlPattern(name="test4", pattern="https://no_help")
test5 = WildCardUrlPattern(name="test5", pattern="https://search{query}")
patterns = URLPatternList(items=[test, test2, test3, test4, test5])
test_file = tmpdir / "urlpatterns.yaml"
with open(test_file, "w") as f:
patterns.save(f)
with open(test_file, "r") as f:
from_file = URLPatternList.load(f)
> assert len(patterns) == len(from_file)
E assert 5 == 9
E + where 5 = len([<yeahyeah_plugins.url_pattern_plugin.core.UrlPattern object at 0x7fa18cfe0a90>, <yeahyeah_plugins.url_pattern_plugin....tern object at 0x7fa18cfe0100>, <yeahyeah_plugins.url_pattern_plugin.core.WildCardUrlPattern object at 0x7fa18cfe0460>])
E + and 9 = len([<yeahyeah_plugins.url_pattern_plugin.core.WildCardUrlPattern object at 0x7fa18cbd46a0>, <yeahyeah_plugins.url_pattern...tern object at 0x7fa18cff1fa0>, <yeahyeah_plugins.url_pattern_plugin.core.WildCardUrlPattern object at 0x7fa18cff14c0>])
yeahyeah_plugins/url_pattern_plugin/tests/test_url_pattern.py:75: AssertionError
________________________________________ test_load_from_file ________________________________________
def test_load_from_file():
"""Test load from file directly"""
file = RESOURCE_PATH / "urlpatterns_example.yaml"
with open(file, "r") as f:
from_file = URLPatternList.load(f)
> assert from_file[2].pattern == "https://uniqcodeПривет.com"
E AssertionError: assert 'https://athing.com' == 'https://uniqcodeПривет.com'
E - https://uniqcodeПривет.com
E + https://athing.com
yeahyeah_plugins/url_pattern_plugin/tests/test_url_pattern.py:89: AssertionError
______________________________________ test_url_pattern_plugin ______________________________________
tmpdir = local('/private/var/folders/gw/ylsybrkd7495cv7h7tqk7jg80000gn/T/pytest-of-joelzhang/pytest-0/test_url_pattern_plugin0')
disable_click_echo = None
def test_url_pattern_plugin(tmpdir, disable_click_echo):
config_file = Path(tmpdir / "test_url_pattern_config.yaml")
assert not config_file.exists()
# file should be created if not exists
plugin = UrlPatternsPlugin.__from_file_path__(config_file_path=config_file)
assert config_file.exists()
items = plugin.get_commands()
> assert len(items) == 3
E assert 5 == 3
E + where 5 = len([<click.core.Command object at 0x7fa18d010280>, <click.core.Command object at 0x7fa18d010100>, <click.core.Command object at 0x7fa18d010af0>, <click.core.Command object at 0x7fa18d010c40>, <click.core.Command object at 0x7fa18d010a60>])
yeahyeah_plugins/url_pattern_plugin/tests/test_url_pattern.py:106: AssertionError