Opened 5 years ago

Closed 5 years ago

#14016 closed defect (fixed)

Failing unit tests on Python3.4

Reported by: Foxboron Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords: python3, unittests
Cc: atagar Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

test_archived_paths                                          [FAILURE]
....

======================================================================
FAIL: test_archived_paths

----
Traceback (most recent call last):

  File "/home/fox/Github/stem3/stem3/test/data/python3/test/unit/descriptor/reader.py", line 368, in test_archived_paths
    self.assertTrue(desc.get_archive_path() in expected_archive_paths)

AssertionError: False is not true

----
...

test_compare_flags                                           [FAILURE]
....

test_votes_by_bandwidth_authorities                          [FAILURE]

======================================================================
FAIL: test_compare_flags
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/mock.py", line 1136, in patched
    return func(*args, **keywargs)
  File "/home/fox/Github/stem3/stem3/test/data/python3/test/unit/tutorial_examples.py", line 353, in test_compare_flags
    self.assertEqual(COMPARE_FLAGS_OUTPUT, stdout_mock.getvalue())
AssertionError: "maat[41 chars]n't: E2BB13AA2F6960CD93ABE5257A825687F3973C62\[365 chars]61\n" != "maat[41 chars]n't: DCAEC3D069DC39AAE43D13C8AF31B5645E05ED61\[365 chars]62\n"
Diff is 931 characters long. Set self.maxDiff to None to see it.

======================================================================
FAIL: test_votes_by_bandwidth_authorities
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/mock.py", line 1136, in patched
    return func(*args, **keywargs)
  File "/home/fox/Github/stem3/stem3/test/data/python3/test/unit/tutorial_examples.py", line 422, in test_votes_by_bandwidth_authorities
    self.assertEqual(VOTES_BY_BANDWIDTH_AUTHORITIES_OUTPUT, stdout_mock.getvalue())
AssertionError: "Getting gabelmoo's vote from http://212.112.245.1[477 chars]ed\n" != "Getting maatuska's vote from http://171.25.193.9:[477 chars]ed\n"
Diff is 808 characters long. Set self.maxDiff to None to see it.

----------------------------------------------------------------------
Ran 6 tests in 0.109s

Child Tickets

Change History (4)

comment:1 Changed 5 years ago by Foxboron

Regarding first fail.

Seems like the TarInfo object changed what the attribute .name returns. It doesn't return the expected name, but a full path to the tar file.

comment:2 Changed 5 years ago by Foxboron

@@ -537,7 +533,7 @@ class DescriptorReader(object):
                 return
 
               desc._set_path(os.path.abspath(target))
-              desc._set_archive_path(entry.name)
+              desc._set_archive_path(tar_entry.name)
               self._unreturned_descriptors.put(desc)
               self._iter_notice.set()
           except TypeError as exc:

This gives the correct result for python2 and 3.

comment:3 Changed 5 years ago by Foxboron

test_votes_by_bandwidth_authorities can be fixed by using an ordered dict.
I suspect the last failing test suffers from the same, tho i find it wierd it does work on python2 if thats the case.

@@ -279,7 +283,8 @@ class TestTutorialExamples(unittest.TestCase):
       # Query all authority votes asynchronously.
 
       downloader = remote.DescriptorDownloader(document_handler = DocumentHandler.DOCUMENT)
-      queries = {}
+      from collections import OrderedDict
+      queries = OrderedDict()
 
       for name, authority in remote.get_authorities().items():
         if authority.v3ident is None:

comment:4 Changed 5 years ago by atagar

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.