Skip to content

Commit

Permalink
merged OCTO-10932-honor-spaces-before-inline-italic-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
OlteanuRares committed Feb 28, 2024
2 parents ca5294e + 3f8a6a8 commit 79e829d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 0 additions & 1 deletion pycaption/scc/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from itertools import product
from collections import defaultdict

COMMANDS = {
'9420': '',
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
sample_scc_tab_offset, sample_scc_with_unknown_commands,
sample_scc_special_and_extended_characters,
sample_scc_with_line_too_long,
sample_scc_with_spaces,
sample_scc_with_break_and_repositioning
)
from tests.fixtures.srt import ( # noqa: F401
Expand Down
13 changes: 13 additions & 0 deletions tests/fixtures/scc.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,16 @@ def sample_scc_with_break_and_repositioning():
00:23:15;11 942c
"""


@pytest.fixture(scope="session")
def sample_scc_with_spaces():
return """\
Scenarist_SCC V1.0
00:00:55;25 9420 942c 942f 9420 9470 97a1 57e5 ece3 ef6d e520 f4ef 9723 2080 2080 2080 91ae 5468 e520 4675 f475 f2e5 20ef e620 57ef f26b ae80
00:00:58;08 942c
00:00:59;10 9420 942c 942f
"""
14 changes: 14 additions & 0 deletions tests/test_scc.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ def test_line_not_breaking_on_break_and_repositioning(

assert expected_lines == actual_lines

def test_spaces_are_respected(self, sample_scc_with_spaces):
expected_lines = ['Welcome to ', 'The Future of Work.']

caption_set = SCCReader().read(sample_scc_with_spaces)
actual_lines = [
node.content
for cap_ in caption_set.get_captions('en-US')
for node in cap_.nodes
if node.type_ == CaptionNode.TEXT
]

assert expected_lines == actual_lines
assert actual_lines[0][-3:] == " " * 3


class TestCoverageOnly:
"""In order to refactor safely, we need coverage of 95% or more.
Expand Down

0 comments on commit 79e829d

Please sign in to comment.