From 4b577e97b88afc864da7c89fad9c1eeb69f53626 Mon Sep 17 00:00:00 2001 From: "Dr. Tilmann Bubeck" Date: Thu, 13 Jun 2024 11:11:02 +0200 Subject: [PATCH] Fixed import statements according flake8 (#281) --- aerofiles/seeyou/converter.py | 2 +- aerofiles/seeyou/reader.py | 3 ++- aerofiles/seeyou/writer.py | 2 +- setup.py | 2 +- tests/flarmcfg/test_writer.py | 4 ++-- tests/igc/test_reader.py | 6 +++--- tests/igc/test_writer.py | 8 ++++---- tests/openair/test_reader.py | 9 +++++---- tests/openair/test_writer.py | 14 ++++++++++++++ tests/seeyou/test_reader.py | 7 ++++--- tests/seeyou/test_writer.py | 6 +++--- tests/welt2000/test_reader.py | 6 +++--- tests/xcsoar/test_writer.py | 9 ++++----- 13 files changed, 47 insertions(+), 31 deletions(-) diff --git a/aerofiles/seeyou/converter.py b/aerofiles/seeyou/converter.py index b5b411f..a35fef8 100644 --- a/aerofiles/seeyou/converter.py +++ b/aerofiles/seeyou/converter.py @@ -1,8 +1,8 @@ from aerofiles.errors import ParserError from aerofiles.util import units -from .reader import Reader from .common import WaypointStyle +from .reader import Reader WAYPOINT_STYLE_MAPPING = { diff --git a/aerofiles/seeyou/reader.py b/aerofiles/seeyou/reader.py index a765408..ecd0143 100644 --- a/aerofiles/seeyou/reader.py +++ b/aerofiles/seeyou/reader.py @@ -1,7 +1,8 @@ -import re import csv +import re from aerofiles.errors import ParserError + from .common import SeeYouFileFormat diff --git a/aerofiles/seeyou/writer.py b/aerofiles/seeyou/writer.py index 7496e2e..a1c37cc 100644 --- a/aerofiles/seeyou/writer.py +++ b/aerofiles/seeyou/writer.py @@ -1,7 +1,7 @@ import datetime -from .converter import WaypointStyle from .common import SeeYouFileFormat +from .converter import WaypointStyle class Writer: diff --git a/setup.py b/setup.py index fa3a51b..6589b32 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import os -from setuptools import setup, find_packages +from setuptools import find_packages, setup GITHUB_URL = 'https://github.com/Turbo87/aerofiles/' diff --git a/tests/flarmcfg/test_writer.py b/tests/flarmcfg/test_writer.py index 17406a2..ce30180 100644 --- a/tests/flarmcfg/test_writer.py +++ b/tests/flarmcfg/test_writer.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -import pytest - from io import BytesIO from aerofiles.flarmcfg import Writer +import pytest + @pytest.fixture() def output(): diff --git a/tests/igc/test_reader.py b/tests/igc/test_reader.py index 8449281..be4f5fc 100644 --- a/tests/igc/test_reader.py +++ b/tests/igc/test_reader.py @@ -3,10 +3,10 @@ import datetime import os -import pytest - -from aerofiles.igc.reader import Reader from aerofiles.igc.reader import LowLevelReader +from aerofiles.igc.reader import Reader + +import pytest def test_decode_A_record(): diff --git a/tests/igc/test_writer.py b/tests/igc/test_writer.py index ed08b17..836b495 100644 --- a/tests/igc/test_writer.py +++ b/tests/igc/test_writer.py @@ -1,12 +1,12 @@ -import pytest -from freezegun import freeze_time - import datetime - from io import BytesIO from aerofiles.igc import Writer +from freezegun import freeze_time + +import pytest + @pytest.fixture() def output(): diff --git a/tests/openair/test_reader.py b/tests/openair/test_reader.py index 41987f7..418d427 100644 --- a/tests/openair/test_reader.py +++ b/tests/openair/test_reader.py @@ -1,14 +1,15 @@ -import pytest - -from os import path from json import load as load_json +from os import path try: from itertools import zip_longest except ImportError: from itertools import izip_longest as zip_longest -from aerofiles.openair.reader import Reader, LowLevelReader, coordinate +from aerofiles.openair.reader import LowLevelReader, Reader, coordinate + +import pytest + DATA = path.join(path.dirname(path.realpath(__file__)), 'data') diff --git a/tests/openair/test_writer.py b/tests/openair/test_writer.py index f26af37..5a1126b 100644 --- a/tests/openair/test_writer.py +++ b/tests/openair/test_writer.py @@ -33,6 +33,12 @@ def test_write_DP(writer): assert writer.fp.getvalue() == b'DP 39:35:00 S 118:59:20 W\r\n' +def test_write_DP_round(writer): + element = {"location": [-39.999999999999, -118.9999999999]} + writer.write_DP(element) + assert writer.fp.getvalue() == b'DP 40:00:00 S 119:00:00 W\r\n' + + def test_write_DC(writer): element = {"center": [39.58333, 118.98888], "radius": 10} writer.write_DC(element) @@ -62,6 +68,14 @@ def test_write_DB(writer): assert writer.fp.getvalue() == b'V X=39:29:42 N 119:46:30 W\r\nDB 39:36:48 N 119:46:06 W, 39:29:54 N 119:36:06 W\r\n' +def test_invalid_record_type(writer): + record = {"type": "terrain"} + with pytest.raises(ValueError) as ex: + writer.write_record(record) + + assert 'unknown record type' in str(ex) + + def test_write_record(writer): record = { "type": "airspace", diff --git a/tests/seeyou/test_reader.py b/tests/seeyou/test_reader.py index 288e4de..e3760f4 100644 --- a/tests/seeyou/test_reader.py +++ b/tests/seeyou/test_reader.py @@ -1,12 +1,13 @@ from os import path -import pytest - from aerofiles.errors import ParserError -from aerofiles.seeyou import Reader, Converter +from aerofiles.seeyou import Converter, Reader + +import pytest from tests import assert_waypoint + FOLDER = path.dirname(path.realpath(__file__)) DATA_PATH = path.join(FOLDER, 'data', 'SEEYOU.CUP') SIMPLE_CUPFILE = path.join(FOLDER, 'data', 'simple.cup') diff --git a/tests/seeyou/test_writer.py b/tests/seeyou/test_writer.py index 9872183..6e311b7 100644 --- a/tests/seeyou/test_writer.py +++ b/tests/seeyou/test_writer.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -import pytest import datetime - from io import BytesIO -from aerofiles.seeyou import Writer, WaypointStyle, ObservationZoneStyle, SeeYouFileFormat +from aerofiles.seeyou import ObservationZoneStyle, SeeYouFileFormat, WaypointStyle, Writer + +import pytest @pytest.fixture() diff --git a/tests/welt2000/test_reader.py b/tests/welt2000/test_reader.py index 5b170b3..6c6c4fb 100644 --- a/tests/welt2000/test_reader.py +++ b/tests/welt2000/test_reader.py @@ -1,10 +1,10 @@ from os import path -import pytest - -from aerofiles.welt2000 import Reader, Converter +from aerofiles.welt2000 import Converter, Reader from aerofiles.welt2000.reader import SURFACES +import pytest + from tests import assert_waypoint diff --git a/tests/xcsoar/test_writer.py b/tests/xcsoar/test_writer.py index a771cfe..c21600a 100644 --- a/tests/xcsoar/test_writer.py +++ b/tests/xcsoar/test_writer.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- -import pytest - -import os.path import datetime - +import os.path from io import BytesIO from aerofiles.xcsoar import ( - Writer, TaskType, PointType, ObservationZoneType, AltitudeReference + AltitudeReference, ObservationZoneType, PointType, TaskType, Writer ) +import pytest + FOLDER = os.path.dirname(os.path.realpath(__file__))