def test_common_path_when_duplicate_entries_of_single_path(self): d = PathList() files = [ "/users/joebloggs/tmp/foo.txt", "/users/joebloggs/tmp/foo.txt" ] d.add(*files) self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp/foo.txt"))
def test_common_path_when_one_path_is_the_common_path(self): d = PathList() files = [ "/users/joebloggs/tmp", "/users/joebloggs/tmp/bolly/operation", "/users/joebloggs/tmp/stay/go", ] d.add(*files) self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp"))
def test_common_path(self): d = PathList() files = [ "/users/joebloggs/tmp/foobar/test", "/users/joebloggs/tmp/baz/fripp", "/users/joebloggs/tmp/elephant/corner", ] d.add(*files) self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp"))
def test_common_path_when_common_prefix_in_filename(self): d = PathList() files = [ "/users/joebloggs/tmp/dissention/perfect", "/users/joebloggs/tmp/disagreement/crimson", "/users/joebloggs/tmp/diatribe/belew", ] d.add(*files) self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp"))
def test_common_different_drive_letter(self): d = PathList() files = [ "D:/users/joebloggs/tmp/foo.txt", "D:/users/joebloggs/tmp/modelman.jpg", "C:/users/joebloggs/tmp/ration.cpp", "C:/users/joebloggs/tmp/bill.project", ] d.add(*files) self.assertEqual(d.common_path(), Path("/"))
def test_common_path_when_lowest_path_is_the_common_path(self): d = PathList() files = [ "/users/joebloggs/tmp/foo.txt", "/users/joebloggs/tmp/modelman.jpg", "/users/joebloggs/tmp/ration.cpp", "/users/joebloggs/tmp/bill.project", ] d.add(*files) self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp"))
def test_common_path_is_slash_when_root(self): d = PathList() files = ["/users/joebloggs/tmp/foo.txt", "/dev/joebloggs/tmp/foo.txt"] d.add(*files) self.assertEqual(d.common_path(), Path("/"))
def test_common_path_is_none_when_no_entries(self): d = PathList() self.assertIsNone(d.common_path())