def test_is_valid_accepts_functions_in_modules(mock_isfile, mock_getmembers): file_path = osp.join(vt.ROOT_DIR, 'foo.py') func_name = 'bar' line = '%s::%s' % (file_path, func_name) mock_isfile.side_effect = lambda _path: _path == file_path mock_function = mock.MagicMock(__name__=func_name) mock_getmembers.side_effect = lambda module, predicate: [mock_function] with mock.patch('validate_testpacks.imp.load_source', autospec=True): assert vt.is_valid(line), '%r should be valid!' % line
def test_is_valid_accepts_comments(): line = '# This is a comment' assert vt.is_valid(line)
def test_is_valid_accepts_relative_paths(mock_isfile): line = osp.join(vt.ROOT_DIR, 'foo.py') mock_isfile.side_effect = lambda _path: _path == line assert vt.is_valid(line), '%r should be valid!' % line mock_isfile.assert_called_once_with(line)