def test_neCase(self): for init, segments in self.testParseStrings: path1 = Path(init) path2 = Path(init) path1.add("new") path2.add(["NEW"]) self.assertNotEquals(path1, path2)
def _initPath(self): result = [] for i, j in self.testParseStrings: result.append((i, j)) for i in self.testInitIterables: result.append((i, i)) for init, segments in result: yield Path(init), segments
def test_parse(self): for parseString, result in self.testParseStrings: self.assertEquals(result, Path.parse(parseString))
def test_addString(self): for init, segments in self.testParseStrings: path = Path(init) self.assertEquals(path.segments, segments) self.assertEquals(path.add(init), path) self.assertEquals(path.segments, segments * 2)
def test_addIterable(self): for iterable in self.testInitIterables: path = Path(iterable) self.assertEquals(path.segments, iterable) self.assertEquals(path.add(iterable), path) self.assertEquals(path.segments, iterable * 2)
def test_loadString(self): for init, segments in self.testParseStrings: path = Path("/") self.assertEquals(0, len(path.segments)) self.assertEquals(path, path.load(init)) self.assertEquals(path.segments, segments)
def test_loadIterable(self): for iterable in self.testInitIterables: path = Path("/") self.assertEquals(0, len(path.segments)) self.assertEquals(path, path.load(iterable)) self.assertEquals(path.segments, iterable)
def test_neNotPath(self): self.assertEquals(NotImplemented, Path("/").__eq__(object()))
def test_addIterableWithNoString(self): iterable = ["one", "two", "three", object()] path = Path("/") self.assertRaises(TypeError, path.add, iterable) self.assertEquals(path.segments, [])
def test_addWrongType(self): path = Path("/") self.assertRaises(TypeError, path.add, object) self.assertEquals(path.segments, [])