Skip to content

Commit

Permalink
Merge pull request #233 from lelutin/test_assertions
Browse files Browse the repository at this point in the history
Standardize test assertions for sample files
  • Loading branch information
richardpenman authored Jun 19, 2024
2 parents 36f1634 + 227126a commit 417236a
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def test_com_allsamples(self):
"creation_date",
"status",
]
fail = 0
total = 0
whois_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "samples", "whois", "*"
Expand Down Expand Up @@ -92,32 +91,15 @@ def date2str4json(obj):
compare_keys = compare_keys.intersection(set(keys_to_test))
for key in compare_keys:
total += 1
if key not in results:
print(
"%s \t(%s):\t Missing in results"
% (
domain,
key,
)
)
fail += 1
continue
self.assertIn(key, results)

result = results.get(key)
if isinstance(result, list):
result = [str(element) for element in result]
if isinstance(result, datetime.datetime):
result = str(result)
expected = expected_results.get(key)
if expected != result:
print("%s \t(%s):\t %s != %s" % (domain, key, result, expected))
fail += 1

if fail:
self.fail(
"%d/%d sample whois attributes were not parsed properly!"
% (fail, total)
)
self.assertEqual(expected, result)

def test_ca_parse(self):
data = """
Expand Down

0 comments on commit 417236a

Please sign in to comment.