gwu-libraries / TweetSets

Service for creating Twitter datasets for research and archiving.
MIT License
26 stars 2 forks source link

unittests failing #58

Closed lwrubel closed 3 years ago

lwrubel commented 4 years ago

Two tests failing.

/home/lwrubel/TweetSets/ENV/lib/python3.8/site-packages/dateutil/parser.py:587: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
  if (isinstance(tzinfos, collections.Callable) or
............FF
======================================================================

FAIL: test_derivatives (tests.test_stats.TestTweetSetStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lwrubel/TweetSets/tests/test_stats.py", line 51, in test_derivatives
    self.assertEqual([('a', 1), ('b', 1)], self.stats.derivatives_stats(local_only=True))
AssertionError: Lists differ: [('a', 1), ('b', 1)] != [DerivativeStat(derivative_type='b', count[45 chars]t=1)]

First differing element 0:
('a', 1)
DerivativeStat(derivative_type='b', count=1)

- [('a', 1), ('b', 1)]
+ [DerivativeStat(derivative_type='b', count=1),
+  DerivativeStat(derivative_type='a', count=1)]

======================================================================
FAIL: test_source_datasets (tests.test_stats.TestTweetSetStats)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lwrubel/TweetSets/tests/test_stats.py", line 42, in test_source_datasets
    self.assertEqual([('a', 1), ('b', 1)], self.stats.source_datasets_stats(local_only=True))
AssertionError: Lists differ: [('a', 1), ('b', 1)] != [SourceDatasetStat(dataset_id='b', count=1[41 chars]t=1)]

- [('a', 1), ('b', 1)]
+ [SourceDatasetStat(dataset_id='b', count=1),
+  SourceDatasetStat(dataset_id='a', count=1)]

----------------------------------------------------------------------
Ran 14 tests in 3.149s

FAILED (failures=2)
dolsysmith commented 4 years ago

I believe the tests are failing because the line

        self.assertEqual([('a', 1), ('b', 1)], self.stats.derivatives_stats(local_only=True))

in test_derivatives (and the similar line in test_source_datasets) is comparing two lists that have the same elements but in a different order. The output of the test seems to indicate that in the result of self.stats.derivatives_stats, the tuple with 'b' comes first.

A solution (using set equality) would be as follows:

        self.assertEqual({('a', 1), ('b', 1)}, set(self.stats.derivatives_stats(local_only=True)))
dolsysmith commented 3 years ago

Closing because issue fixed in #61.