cdown / srt

A simple library and set of tools for parsing, modifying, and composing SRT files.
MIT License
465 stars 44 forks source link

\n\r\n collapse may cause \n\n in strict content #59

Closed cdown closed 4 years ago

cdown commented 4 years ago

Broken even in release, although it's an unlikely case to come across in the real world:

======================================================================
FAIL: test_srt.test_compose_and_parse_strict_mode
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/cdown/git/srt/.tox/system/lib/python3.7/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/cdown/git/srt/tests/test_srt.py", line 214, in test_compose_and_parse_strict_mode
    @example(content='0\n\r\n0')
  File "/home/cdown/git/srt/.tox/system/lib/python3.7/site-packages/hypothesis/core.py", line 1052, in wrapped_test
    execute_explicit_examples(state, wrapped_test, arguments, kwargs)
  File "/home/cdown/git/srt/.tox/system/lib/python3.7/site-packages/hypothesis/core.py", line 368, in execute_explicit_examples
    print_example=True,
  File "/home/cdown/git/srt/.tox/system/lib/python3.7/site-packages/hypothesis/core.py", line 624, in execute_once
    result = self.test_runner(data, run)
  File "/home/cdown/git/srt/.tox/system/lib/python3.7/site-packages/hypothesis/executors.py", line 56, in default_new_style_executor
    return function(data)
  File "/home/cdown/git/srt/.tox/system/lib/python3.7/site-packages/hypothesis/core.py", line 620, in run
    return test(*args, **kwargs)
  File "/home/cdown/git/srt/tests/test_srt.py", line 214, in test_compose_and_parse_strict_mode
    @example(content='0\n\r\n0')
  File "/home/cdown/git/srt/.tox/system/lib/python3.7/site-packages/hypothesis/core.py", line 544, in test
    result = self.test(*args, **kwargs)
  File "/home/cdown/git/srt/tests/test_srt.py", line 226, in test_compose_and_parse_strict_mode
    assert_false("\n\n" in parsed_strict.content)
AssertionError: True is not false
-------------------- >> begin captured stdout << ---------------------
Falsifying example: test_compose_and_parse_strict_mode(
    content='0\n\r\n0',
)

We need to collapse all whitespace instead of looking for \n\n.

Caught by release tests after many runs in https://travis-ci.org/cdown/srt/jobs/635807901.