Skip to content

Commit

Permalink
tune tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Sep 28, 2023
1 parent 3ed5d35 commit ec56b28
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_serializable_no_defaultNS(self) -> None:
"""regression test for https://github.com/madpah/serializable/issues/12"""
from xml.etree import ElementTree
xmlns = 'http://the.phoenix.project/testing/defaultNS'
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-no-defaultNS.SNAPSHOT.xml')) as expected_xml:
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-defaultNS-unset.SNAPSHOT.xml')) as expected_xml:
expected = expected_xml.read()
data = deepcopy(ThePhoenixProject_v1)
data._authors = {'Karl Ranseier', } # only one item, so order is no issue
Expand All @@ -90,13 +90,14 @@ def test_serializable_no_defaultNS(self) -> None:
encoding='unicode', xml_declaration=True,
)
# byte-wise string compare is intentional!
self.maxDiff = None
self.assertEqual(expected, actual)

def test_serializable_with_defaultNS(self) -> None:
"""regression test for https://github.com/madpah/serializable/issues/12"""
from xml.etree import ElementTree
xmlns = 'http://the.phoenix.project/testing/defaultNS'
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-with-defaultNS.SNAPSHOT.xml')) as expected_xml:
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-defaultNS-isset.SNAPSHOT.xml')) as expected_xml:
expected = expected_xml.read()
data = deepcopy(ThePhoenixProject_v1)
data._authors = {'Karl Ranseier', } # only one item, so order is no issue
Expand All @@ -107,6 +108,7 @@ def test_serializable_with_defaultNS(self) -> None:
default_namespace=xmlns,
)
# byte-wise string compare is intentional!
self.maxDiff = None
self.assertEqual(expected, actual)

# endregion test_serialize
Expand Down Expand Up @@ -206,28 +208,28 @@ def test_deserialize_tfp_sc1(self) -> None:
def test_deserializable_with_defaultNS(self) -> None:
"""regression test for https://github.com/madpah/serializable/issues/11"""
expected = ThePhoenixProject
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-with-defaultNS-v4.xml')) as fixture_xml:
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-defaultNS-isset-v4.xml')) as fixture_xml:
actual = Book.from_xml(fixture_xml)
self.assertDeepEqual(expected, actual)

def test_deserializable_no_defaultNS_explicite(self) -> None:
def test_deserializable_no_defaultNS_explicit(self) -> None:
"""regression test for https://github.com/madpah/serializable/issues/11"""
expected = ThePhoenixProject
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-no-defaultNS-v4.xml')) as fixture_xml:
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-defaultNS-unset-v4.xml')) as fixture_xml:
actual = Book.from_xml(fixture_xml, 'http://the.phoenix.project/testing/defaultNS')
self.assertDeepEqual(expected, actual)

def test_deserializable_no_defaultNS_autodetect(self) -> None:
"""regression test for https://github.com/madpah/serializable/issues/11"""
expected = ThePhoenixProject
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-no-defaultNS-v4.xml')) as fixture_xml:
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-defaultNS-unset-v4.xml')) as fixture_xml:
actual = Book.from_xml(fixture_xml)
self.assertDeepEqual(expected, actual)

def test_deserializable_mixed_defaultNS_autodetect(self) -> None:
"""regression test for https://github.com/madpah/serializable/issues/11"""
expected = ThePhoenixProject
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-no-defaultNS-v4.xml')) as fixture_xml:
with open(os.path.join(FIXTURES_DIRECTORY, 'the-phoenix-project-defaultNS-mixed-v4.xml')) as fixture_xml:
actual = Book.from_xml(fixture_xml)
self.assertDeepEqual(expected, actual)

Expand Down

0 comments on commit ec56b28

Please sign in to comment.