def test_read_withFileContainingPointsSegmentsPolygons_shouldReturnListOfElements(self): expected_points = reader.read_points("data/test/geocomp/common/io/only_points_expected.txt") expected_segments = reader.read_segments("data/test/geocomp/common/io/only_segments_expected.txt") expected_polygons = reader.read_polygons("data/test/geocomp/common/io/only_polygons_expected.txt") actual = read("data/test/geocomp/common/io/pt_seg_poly.txt") for e in actual: if type(e) is Point: self.assertIn(e, expected_points) if type(e) is Segment: self.assertIn(e, expected_segments) if type(e) is Polygon: self.assertIn(e, expected_polygons)
def open_file(self, event=None): "abre um arquivo de entrada" #if self.in_algorithm: return selection = os.path.join(self.filelist.directory, self.selected_file.get()) if os.path.isdir(selection): self.update_files(selection) return self.input = io.read(selection) geocomp.plot_input(self.input) self.current_filename = self.selected_file.get() self.reset_labels() self.current_algorithm = None
def test_read_withFileContainingOnlyPolygons_shouldReturnListOfPolygons(self): expected = reader.read_polygons("data/test/geocomp/common/io/only_polygons_expected.txt") self.assertCountEqual(expected, read("data/test/geocomp/common/io/only_polygons.txt"))
def test_read_withFileContainingOnlyCommentaries_shouldReturnEmptyList(self): self.assertEqual([], read("data/test/geocomp/common/io/only_commentaries.txt"))
def test_read_withEmptyFile_shouldReturnEmptyList(self): self.assertEqual([], read("data/test/geocomp/common/io/empty_file.txt"))
def test_read_withFileContainingInvalidInput_shouldRaiseValueError(self): with self.assertRaises(ValueError): read("data/test/geocomp/common/io/error_file.txt")
def test_read_withNonexistentFile_shouldRaiseFileNotFoundError(self): with self.assertRaises(FileNotFoundError): read("nonexistent")
def test_read_withNoneTypeArgument_shouldRaiseTypeError(self): with self.assertRaises(TypeError): read(None)