savoirfairelinux / num2words

Modules to convert numbers to words. 42 --> forty-two
GNU Lesser General Public License v2.1
824 stars 501 forks source link

Tests fail on Windows #401

Open aliaafee opened 3 years ago

aliaafee commented 3 years ago

Expected Behaviour

Tests complete successfully.

Actual Behaviour

Test fails at test_cli_list_converters (tests.test_cli.CliTestCase) and test_cli_list_langs (tests.test_cli.CliTestCase)

  ======================================================================
  FAIL: test_cli_list_converters (tests.test_cli.CliTestCase)
  You should be able to list all available converters
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "c:\users\ali\projects\tmp\num2words\tests\test_cli.py", line 74, in test_cli_list_converters
      self.assertEqual(
  AssertionError: Lists differ: ['cardinal', 'currency', 'ordinal', 'ordinal_num', 'year'] != ['cardinal\n\ncurrency\n\nordinal\n\nordinal_num\n\nyear']

  First differing element 0:
  'cardinal'
  'cardinal\n\ncurrency\n\nordinal\n\nordinal_num\n\nyear'

  First list contains 4 additional elements.
  First extra element 1:
  'currency'

  - ['cardinal', 'currency', 'ordinal', 'ordinal_num', 'year']
  + ['cardinal\n\ncurrency\n\nordinal\n\nordinal_num\n\nyear']

  ======================================================================
  FAIL: test_cli_list_langs (tests.test_cli.CliTestCase)
  You should be able to list all availabe languages
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "c:\users\ali\projects\tmp\num2words\tests\test_cli.py", line 60, in test_cli_list_langs
      self.assertEqual(
  AssertionError: Lists differ: ['ar', 'cz', 'de', 'dk', 'en', 'en_IN', 'es',[214 chars]'vi'] != ['ar\n\ncz\n\nde\n\ndk\n\nen\n\nen_IN\n\nes\n[214 chars]nvi']

  First differing element 0:
  'ar'
  'ar\n\ncz\n\nde\n\ndk\n\nen\n\nen_IN\n\nes\n[213 chars]\nvi'

  First list contains 39 additional elements.
  First extra element 1:
  'cz'

  Diff is 1938 characters long. Set self.maxDiff to None to see it.

  ----------------------------------------------------------------------

Steps to reproduce

Remarks

The error seems to be occurring because delegator.py returns output with line termination "\n\n", while the test suite expects the line termination to be os.linesep (which is "\r\n" on windows). According to subprocess documentation "For stdout and stderr, all line endings in the output will be converted to '\n'." irrespective of platform, this would suggest that the use of os.linesep is unnecessary to split the output. But the issue is that on windows the lines are terminated by "\n\n" and not just "\n" as in other platforms. This might be bug in subprocess itself.

Zelinskiy-Aleksandr commented 3 years ago

Fixed in the pull request:

Fixed: Tests fail on Windows #401