Skip to content

Commit

Permalink
CI: Add Flake8 check for selected tests (OSGeo#2199)
Browse files Browse the repository at this point in the history
grass.jupyter and grass.script tests are almost Flake8 compliant. This fixes the reported issues and removes Python 2 specific check.

A new step in the flake8 job checks explicitly for the files in the two testsuite directories. (There is no way in Flake8 itself to include previosly excluded files which is needed because testsuite directories are ignored in the main .flake8 file and here we need to check them.)
  • Loading branch information
wenzeslaus authored and neteler committed Nov 7, 2023
1 parent 0e3247f commit 1db66bc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ jobs:
- name: Run Flake8
run: |
flake8 --count --statistics --show-source --jobs=$(nproc) .
- name: Run Flake8 on additional files
run: |
flake8 --count --statistics --show-source --jobs=$(nproc) python/grass/{script,jupyter}/testsuite/
2 changes: 1 addition & 1 deletion python/grass/jupyter/testsuite/grassrenderer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def can_import_ipython():
"""Test folium import to see if test can be run."""
try:
import IPython
import IPython # noqa

return True
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion python/grass/jupyter/testsuite/interactivemap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
def can_import_folium():
"""Test folium import to see if test can be run."""
try:
import folium
import folium # noqa

return True
except ImportError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Tests of start_command function family (location independent)
"""

import sys
from grass.gunittest.case import TestCase
from grass.gunittest.main import test

Expand Down Expand Up @@ -98,10 +97,7 @@ def test_write_labels_unicode(self):
)
res = read_command("r.category", map=self.raster, separator=":").strip()
self.assertEquals(res, "1:kůň\n2:kráva\n3:ovečka\n4:býk")
if sys.version_info.major >= 3:
self.assertIsInstance(res, str)
else:
self.assertIsInstance(res, unicode)
self.assertIsInstance(res, str)

def test_write_labels_bytes(self):
"""This tests if Python module works"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Tests of start_command function family in nc location"""

LOCATION = "nc"

from grass.gunittest.case import TestCase
from grass.gunittest.main import test

from grass.script.core import start_command, PIPE

LOCATION = "nc"


class TestPythonKeywordsInParameters(TestCase):
"""Tests additional underscore syntax which helps to avoid Python keywords
Expand Down

0 comments on commit 1db66bc

Please sign in to comment.