tests for module name/position

This commit is contained in:
David Halter
2013-08-16 22:25:35 +04:30
parent 51468b1e09
commit 098397aa79

View File

@@ -19,11 +19,15 @@ class TestCallAndName():
return stmt.get_commands()[0]
def test_name_and_call_positions(self):
call = self.get_call('name\ncall, something_else')
name = call.name
assert str(name) == 'name'
assert name.start_pos == call.start_pos == (1, 0)
assert name.end_pos == call.end_pos == (1, 4)
call = self.get_call('name\nsomething_else')
assert str(call.name) == 'name'
assert call.name.start_pos == call.start_pos == (1, 0)
assert call.name.end_pos == call.end_pos == (1, 4)
call = self.get_call('1.0\n')
assert call.name == 1.0
assert call.name.start_pos == call.start_pos == (1, 0)
assert call.name.end_pos == call.end_pos == (1, 3)
def test_call_type(self):
call = self.get_call('hello')
@@ -40,3 +44,16 @@ class TestCallAndName():
call = self.get_call('"hello"')
assert call.type == pr.Call.STRING
assert call.name == 'hello'
def test_module():
module = Parser('asdf', 'example.py', no_docstr=True).module
name = module.name
assert str(name) == 'example'
assert name.start_pos == (0, 0)
assert name.end_pos == (0, 0)
module = Parser('asdf', no_docstr=True).module
name = module.name
assert str(name) == ''
assert name.start_pos == (0, 0)
assert name.end_pos == (0, 0)