def test__eq__not_match_values(self): self.assertFalse( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == { 0: { 1: [0, 2] }, 1: {} })
def test__eq__match(self): self.assertTrue( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == { 0: { 1: [0, 1] }, 1: {} })
def test__eq__not_match_keys(self): self.assertFalse( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == { 2: { 2: [0, 1] }, 1: {} })
def test_str(self): res = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) # Since run in parallel the order is not deterministic expected_valid = [ "AllPairsPathMapping{1: PathMapping{}, 0: PathMapping{1: [0, 1]}}", "AllPairsPathMapping{0: PathMapping{1: [0, 1]}, 1: PathMapping{}}", ] self.assertIn(str(res), expected_valid)
def test__ne__match(self): self.assertFalse( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) != { 0: { 1: [0, 1] }, 1: {} })
def test_items(self): items = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn).items() # Since run in parallel the order is not deterministic expected_valid = [ [(0, { 1: [0, 1] }), (1, {})], [(1, {}), (0, { 1: [0, 1] })], ] self.assertIn(list(items), expected_valid)
def test_not_contains(self): res = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) self.assertNotIn(2, res)
def test__ne__invalid_type(self): self.assertTrue( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) != {"a": {}})
def test__eq__invalid_type(self): self.assertFalse( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == {"a": []})
def test_keys(self): keys = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn).keys() self.assertEqual([0, 1], list(sorted(keys)))
def test_index_error(self): res = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) with self.assertRaises(IndexError): res[42]
def test_hash(self): res = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) hash_res = hash(res) self.assertIsInstance(hash_res, int) # Assert hash is stable self.assertEqual(hash_res, hash(res))
def test_pickle(self): paths = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) paths_pickle = pickle.dumps(paths) paths_copy = pickle.loads(paths_pickle) self.assertEqual(paths, paths_copy)
def test_deepcopy(self): paths = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) paths_copy = copy.deepcopy(paths) self.assertEqual(paths, paths_copy)
def test__gt__not_implemented(self): with self.assertRaises(NotImplementedError): retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) > { 1: [0, 2] }
def test__eq__different_length(self): self.assertFalse( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == { 1: [0, 1], 2: [0, 2] })
def test_eq__same_type(self): self.assertEqual( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn), retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn), )
def test_values(self): values = retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn).values() # Since run in parallel the order is not deterministic expected_valid = [[{1: [0, 1]}, {}], [{}, {1: [0, 1]}]] self.assertIn(list(values), expected_valid)
def test__eq__invalid_inner_type(self): self.assertFalse( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) == {0: { 1: None }})
def test_iter(self): mapping_iter = iter( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn)) output = list(sorted(mapping_iter)) self.assertEqual(output, [0, 1])
def test_all_pairs_dijkstra_shortest_paths(self): res = retworkx.all_pairs_dijkstra_shortest_paths( self.graph, lambda _: 1) self.assertIsInstance(res, retworkx.AllPairsPathMapping)
def test__ne__not_match_values(self): self.assertTrue( retworkx.all_pairs_dijkstra_shortest_paths(self.dag, self.fn) != {1: [0, 2]})