def test_find_failed_at_root(self): """Should return None if top-level directory has no project""" directory = os.path.dirname(os.path.realpath(__file__)) subdirectory = os.path.join(directory, 'fake') with patch('os.path.dirname', return_value=subdirectory) as func: with self.assertRaises(FileNotFoundError): steptest.find_project_directory(subdirectory) func.assert_called_once_with(subdirectory)
def test_find_in_grandparent_path(self): """ should find a project in the grandparent directory """ directory = os.path.dirname(os.path.realpath(__file__)) subdirectory = os.path.join(directory, 'fake', 'fake') result = steptest.find_project_directory(subdirectory) self.assertEqual(directory, result)
def test_find_failed_at_root(self): """ should return None if top-level directory has no project """ directory = os.path.dirname(os.path.realpath(__file__)) subdirectory = os.path.join(directory, 'fake') with patch('os.path.dirname', return_value=subdirectory) as func: result = steptest.find_project_directory(subdirectory) func.assert_called_once_with(subdirectory) self.assertIsNone(result)
def test_find_in_grandparent_path(self): """Should find a project in the grandparent directory""" directory = os.path.dirname(os.path.realpath(__file__)) subdirectory = os.path.join(directory, 'fake', 'fake') result = steptest.find_project_directory(subdirectory) self.assertEqual(directory, result)
def test_find_in_current_path(self): """Should find a project in this file's directory""" directory = os.path.dirname(os.path.realpath(__file__)) result = steptest.find_project_directory(directory) self.assertEqual(directory, result)
def test_find_in_parent_path(): """Should find a project in the parent directory""" directory = os.path.dirname(os.path.realpath(__file__)) subdirectory = os.path.join(directory, 'fake') result = steptest.find_project_directory(subdirectory) assert directory == result