def test_call_base(self, mocker): mock_Section = mocker.patch.object(template, 'Section') values = {'sections': {}} start_coord = location.Coordinate('path', 23) end_coord = location.Coordinate('path', 42) start_toks = [ perfile.Token(perfile.TOK_WORD, 'section'), perfile.Token(perfile.TOK_CHAR, '('), perfile.Token(perfile.TOK_WORD, 'var1'), perfile.Token(perfile.TOK_CHAR, ','), perfile.Token(perfile.TOK_WORD, 'var2'), perfile.Token(perfile.TOK_CHAR, ','), perfile.Token(perfile.TOK_WORD, 'var3'), perfile.Token(perfile.TOK_CHAR, ')'), perfile.Token(perfile.TOK_CHAR, '{'), ] end_toks = [] obj = template.SectionDirective(values, start_coord, start_toks) result = obj(end_coord, 'buf', end_toks) assert result is None assert values == { 'sections': { 'section': mock_Section.return_value }, } mock_Section.assert_called_once_with( location.CoordinateRange('path', 23, 42), 'section', {'var1', 'var2', 'var3'}, 'buf', )
def test_base(self, mocker): mock_InsertSection = mocker.patch.object(template, 'InsertSection') values = {'structure': []} coord = location.Coordinate('path', 23) toks = [perfile.Token(perfile.TOK_WORD, 'section')] result = template.insert(values, coord, toks) assert result is None assert values == { 'structure': [mock_InsertSection.return_value], } mock_InsertSection.assert_called_once_with( location.CoordinateRange('path', 23, 23), 'section')
def test_call_base(self, mocker): mock_Literal = mocker.patch.object(template, 'Literal') values = {'structure': []} start_coord = location.Coordinate('path', 23) end_coord = location.Coordinate('path', 42) start_toks = [perfile.Token(perfile.TOK_CHAR, '{')] end_toks = [] obj = template.LiteralDirective(values, start_coord, start_toks) result = obj(end_coord, 'buf', end_toks) assert result is None assert values == { 'structure': [mock_Literal.return_value], } mock_Literal.assert_called_once_with( location.CoordinateRange('path', 23, 42), 'buf')
def test_call_base(self, mocker): mock_Define = mocker.patch.object(template, 'Define') values = {'defines': {}} start_coord = location.Coordinate('path', 23) end_coord = location.Coordinate('path', 42) start_toks = [ perfile.Token(perfile.TOK_WORD, 'define'), perfile.Token(perfile.TOK_CHAR, '{'), ] end_toks = [] obj = template.DefineDirective(values, start_coord, start_toks) result = obj(end_coord, 'buf', end_toks) assert result is None assert values == { 'defines': { 'define': mock_Define.return_value }, } mock_Define.assert_called_once_with( location.CoordinateRange('path', 23, 42), 'define', 'buf')
def test_ne_unequal_end(self): obj1 = location.CoordinateRange('file.name', 23, 42) obj2 = location.CoordinateRange('file.name', 23, 43) assert obj1.__ne__(obj2)
def test_ne_other(self): obj = location.CoordinateRange('file.name', 23, 42) assert obj.__ne__(other)
def test_ne_equal(self): obj1 = location.CoordinateRange('file.name', 23, 42) obj2 = location.CoordinateRange('file.name', 23, 42) assert not obj1.__ne__(obj2)
def test_eq_unequal_start(self): obj1 = location.CoordinateRange('file.name', 23, 42) obj2 = location.CoordinateRange('file.name', 24, 42) assert not obj1.__eq__(obj2)
def test_str_multiline(self): obj = location.CoordinateRange('file.name', 23, 42) result = str(obj) assert result == 'file.name:23-42'
def test_str_oneline(self): obj = location.CoordinateRange('file.name', 23, 23) result = str(obj) assert result == 'file.name:23'
def test_init(self): result = location.CoordinateRange('file.name', 23, 42) assert result.path == 'file.name' assert result.start == 23 assert result.end == 42