tanminhnu / python-gflags

Automatically exported from code.google.com/p/python-gflags
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Test suite doesn't pass #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Extract tarball.
2. Run unit tests (python gflags_unittest.py)

What is the expected output? What do you see instead?
The test suite should pass.

Instead, I get this:
Traceback (most recent call last):
  File "gflags_unittest.py", line 51, in <module>
    import test_module_baz as module_baz
ImportError: No module named test_module_baz

What version of the product are you using? On what operating system?
1.5.1 on Ubuntu 11.04

Please provide any additional information below.

Original issue reported on code.google.com by soren@linux2go.dk on 14 Jun 2011 at 12:03

GoogleCodeExporter commented 8 years ago
I see this is addressed in SVN, but not included in a release. Running the test 
suite with Python 2.7 yields a number of errors (Python 2.6 works fine):

.......EError: FLAGS.MainModuleHelp() didn't return the expected result.
Got:

gflags_unittest.py:
  --[no]debug: debughelp
    (default: 'false')
  -?,--[no]help: show this help
  --[no]helpshort: show usage only for this module
  --[no]helpxml: like --help, but generates XML output
  --kwery: <who|what|why|where|when>: ?
  --l: how long to be
    (default: '9223372032559808512')
    (an integer)
  --letters: a list of letters
    (default: 'a,b,c')
    (a comma separated list)
  --name: namehelp
    (default: 'Bob')
  --[no]noexec: boolean flag with no as prefix
    (default: 'true')
  --numbers: a list of numbers
    (default: '1,2,3')
    (a comma separated list)
  --[no]q: quiet mode
    (default: 'true')
  --[no]quack: superstring of 'q'
    (default: 'false')
  -r,--repeat: how many times to repeat (0-5)
    (default: '4')
    (a non-negative integer)
  --x: how eXtreme to be
    (default: '3')
    (an integer)
[End of got]
Number of help lines = 31, expected 61
One discrepancy: Got:
  -?,--[no]help: show this help
Expected:
  -u,--[no]dup1: runhelp d12
F...EE.....Warning: Hit circular flagfile dependency: 
/tmp/flags_unittest/UnitTestFile3.tst
...........FEE....
======================================================================
ERROR: test_flags (__main__.FlagsUnitTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_unittest.py", line 194, in test_flags
    self.assertEqual(keys, reg_flags)
  File "/usr/lib/python2.7/unittest/case.py", line 503, in assertEqual
    assertion_func(first, second, msg=msg)
TypeError: assertListEqual() got an unexpected keyword argument 'msg'

======================================================================
ERROR: testKeyFlags (__main__.KeyFlagsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_unittest.py", line 1595, in testKeyFlags
    [])
  File "gflags_unittest.py", line 1548, in assertListEqual
    self.assertEqual(Sorted(list1), Sorted(list2))
  File "/usr/lib/python2.7/unittest/case.py", line 503, in assertEqual
    assertion_func(first, second, msg=msg)
TypeError: assertListEqual() got an unexpected keyword argument 'msg'

======================================================================
ERROR: testKeyFlagsWithNonDefaultFlagValuesObject (__main__.KeyFlagsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_unittest.py", line 1665, in testKeyFlagsWithNonDefaultFlagValuesObject
    [])
  File "gflags_unittest.py", line 1548, in assertListEqual
    self.assertEqual(Sorted(list1), Sorted(list2))
  File "/usr/lib/python2.7/unittest/case.py", line 503, in assertEqual
    assertion_func(first, second, msg=msg)
TypeError: assertListEqual() got an unexpected keyword argument 'msg'

======================================================================
ERROR: testMultiNumericalFlags (__main__.MultiNumericalFlagsTest)
Test multi_int and multi_float flags.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_unittest.py", line 836, in testMultiNumericalFlags
    self.assertListEqual(FLAGS.get('m_int', None), int_defaults)
  File "gflags_unittest.py", line 818, in assertListEqual
    self.assertEqual(Sorted(list1), Sorted(list2))
  File "/usr/lib/python2.7/unittest/case.py", line 503, in assertEqual
    assertion_func(first, second, msg=msg)
TypeError: assertListEqual() got an unexpected keyword argument 'msg'

======================================================================
ERROR: testSingleValueDefault (__main__.MultiNumericalFlagsTest)
Test multi_int and multi_float flags with a single default value.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_unittest.py", line 858, in testSingleValueDefault
    self.assertListEqual(FLAGS.get('m_int1', None), [int_default])
  File "gflags_unittest.py", line 818, in assertListEqual
    self.assertEqual(Sorted(list1), Sorted(list2))
  File "/usr/lib/python2.7/unittest/case.py", line 503, in assertEqual
    assertion_func(first, second, msg=msg)
TypeError: assertListEqual() got an unexpected keyword argument 'msg'

======================================================================
FAIL: test_main_module_help (__main__.FlagsUnitTest)
Test MainModuleHelp().
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_unittest.py", line 811, in test_main_module_help
    self.assertMultiLineEqual(expected_help, helpstr)
  File "gflags_unittest.py", line 119, in assertMultiLineEqual
    self.assert_(MultiLineEqual(expected, actual))
AssertionError: False is not true

======================================================================
FAIL: testBadMultiNumericalFlags (__main__.MultiNumericalFlagsTest)
Test multi_int and multi_float flags with non-parseable values.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "gflags_unittest.py", line 879, in testBadMultiNumericalFlags
    flags.DEFINE_multi_float, 'm_float2', ['abc'], 'desc')
  File "gflags_unittest.py", line 825, in assertRaisesWithRegexpMatch
    '"%s" does not match "%s"' % (regexp, why))
AssertionError: "flag --m_float2=abc: invalid literal for float\(\): abc" does 
not match "flag --m_float2=abc: could not convert string to float: abc"

----------------------------------------------------------------------
Ran 37 tests in 0.025s

FAILED (failures=2, errors=5)

Original comment by soren@linux2go.dk on 14 Jun 2011 at 12:30

GoogleCodeExporter commented 8 years ago
The attached patch makes the test suite pass with python 2.7.

Original comment by soren@linux2go.dk on 14 Jun 2011 at 12:55

Attachments:

GoogleCodeExporter commented 8 years ago
Drat! -- I just released gflags 1.6, without having seen this bug report.  I 
think I'm not getting mail for these bug reports for some reason.  I'll look 
into the project settings about that.

I refactored the tests for gflags 1.6, which may have improved things somewhat, 
but probably don't fix all tests for python 2.7.  If not, can you send a 
revised patch that fixes it?  I'll get that in for the next release.

Original comment by csilv...@gmail.com on 29 Jul 2011 at 7:54

GoogleCodeExporter commented 8 years ago
It looks like the problem here is that unittest defines assertListEqual in 
python 2.7, but not before.

However, according to
   http://docs.python.org/library/unittest.html
the same is true for assertMultiLineEqual.  I'd think that we'd want to fix 
both of them.

Ah, I see, unittest.py uses assertListEqual internally, and gets upset at our 
override.  That's not true of assertMultiLineEqual.  Still, I think it's better 
to treat them the same.  OK, I'll look to fix these for the next release.

Original comment by csilv...@gmail.com on 2 Aug 2011 at 1:55

GoogleCodeExporter commented 8 years ago
This should be fixed as of r24.  Feel free to reopen if that's not true (I 
don't have python2.7 handy to test it).

Original comment by csilv...@gmail.com on 26 Aug 2011 at 12:10