ExcaliburZero / jekyll-helper

A program that serves as a basic GUI for Jekyll.
MIT License
4 stars 0 forks source link

AssertionError: Lists differ: ['AboutDialog', 'AboutJekyllHe... != ['AboutDialog', 'AboutJekyllHe... #6

Closed ExcaliburZero closed 9 years ago

ExcaliburZero commented 9 years ago

The following error shows up in the Travis CI tests with Python 2.7, but not 3.2.

Python 2.7

======================================================================
FAIL: test_AboutJekyllHelperDialog_members (test_example.TestExample)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/ExcaliburZero/jekyll-helper/tests/test_example.py", line 23, in test_AboutJekyllHelperDialog_members
    self.assertEqual(self.AboutJekyllHelperDialog_members, public_members)
AssertionError: Lists differ: ['AboutDialog', 'AboutJekyllHe... != ['AboutDialog', 'AboutJekyllHe...
First differing element 2:
gettext
logger
First list contains 1 additional elements.
First extra element 4:
logging
- ['AboutDialog', 'AboutJekyllHelperDialog', 'gettext', 'logger', 'logging']
?                                            -----------
+ ['AboutDialog', 'AboutJekyllHelperDialog', 'logger', 'logging']
ExcaliburZero commented 9 years ago

It looks like this error was caused by the following code in the test script:

class TestExample(unittest.TestCase):
    def setUp(self):
        self.AboutJekyllHelperDialog_members = [
        'AboutDialog', 'AboutJekyllHelperDialog', 'gettext', 'logger', 'logging']

    def test_AboutJekyllHelperDialog_members(self):
        all_members = dir(AboutJekyllHelperDialog)
        public_members = [x for x in all_members if not x.startswith('_')]
        public_members.sort()
        self.assertEqual(self.AboutJekyllHelperDialog_members, public_members)

It gets a list of all of the public members of AboutJekyllHelperDialog, however it excludes all such members whose names begin with _. It seems that as the about dialogue file imports gettext as shown below it is incorrectly excluded from the list, as it is imported as the exclusion character.

from locale import gettext as _

Thus to fix the error I had to manually append gettext to the list in the test file.