Skip to content

Commit 3353cc5

Browse files
Denis-AverinivankamkinIvan Kamkin
authored
Test latest python version on all OS (#46)
* Test latest python version on all OS * New version of python added * Fixing tests in Python 3.11 Co-authored-by: ivankamkin <109517020+ivankamkin@users.noreply.github.com> Co-authored-by: Ivan Kamkin <234-Ivan.Kamkin@users.noreply.git.saltov.dynabic.com>
1 parent 6744a2d commit 3353cc5

7 files changed

Lines changed: 76 additions & 20 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v3
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Latest Python Support
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
# Define the job to run before your matrix job
11+
get-python-versions:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
python-matrix: ${{ steps.get-python-versions-action.outputs.latest-python-versions }}
15+
steps:
16+
- uses: snok/latest-python-versions@v1
17+
id: get-python-versions-action
18+
with:
19+
min-version: '3.10'
20+
21+
test:
22+
needs: [get-python-versions]
23+
runs-on: ${{ matrix.operating-system }}
24+
strategy:
25+
matrix:
26+
operating-system: [ ubuntu-latest, windows-latest, macOS-latest ]
27+
python-version: ${{ fromJson(needs.get-python-versions.outputs.python-matrix) }}
28+
29+
steps:
30+
- uses: actions/checkout@v3
31+
- name: Set up Python on ${{ matrix.operating-system }}
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
- name: Install dependencies
36+
run: |
37+
python3 -m pip install -r requirements.txt -r test-requirements.txt
38+
- name: Lint
39+
run: |
40+
python3 -m black --line-length=120 --check .
41+
python3 -m check_python_versions --expect 2.7,3.5- --only setup.py
42+
- name: Test
43+
env:
44+
TEST_CONFIGURATION_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
45+
run: python3 -Werror -m pytest

.github/workflows/python-package.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python package
4+
name: Test
55

66
on:
77
push:
@@ -15,12 +15,13 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18+
# see https://www.python.org/downloads/
1819
python-version: ['2.7', '3.5', '3.10']
1920

2021
steps:
21-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2223
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v4
2425
with:
2526
python-version: ${{ matrix.python-version }}
2627
- name: Install dependencies

example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
config = Configuration(
99
client_id="Client Id from https://dashboard.aspose.cloud/applications",
1010
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
11-
access_token=os.environ.get("TEST_CONFIGURATION_ACCESS_TOKEN") # Only for testing in CI, remove this line
11+
access_token=os.environ.get("TEST_CONFIGURATION_ACCESS_TOKEN"), # Only for testing in CI, remove this line
1212
)
1313

1414
api = BarcodeApi(ApiClient(config))
1515

1616
# Generate barcode
1717
response = api.get_barcode_generate(EncodeBarcodeType.QR, "Example")
18-
with open('example.png', 'wb') as f:
18+
with open("example.png", "wb") as f:
1919
f.write(response.data)
2020
print("Barcode saved to file 'example.png'")
2121

2222
# Recognize barcode
23-
response = api.post_barcode_recognize_from_url_or_content(image='example.png', preset=PresetType.HIGHPERFORMANCE)
23+
response = api.post_barcode_recognize_from_url_or_content(image="example.png", preset=PresetType.HIGHPERFORMANCE)
2424
pprint(response)

setup.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@
3737
# prerequisite: setuptools
3838
# http://pypi.python.org/pypi/setuptools
3939

40-
REQUIRES = [
41-
"certifi>=2017.4.17",
42-
"python-dateutil>=2.1",
43-
"six>=1.10",
44-
"urllib3>=1.23"
45-
]
40+
REQUIRES = ["certifi>=2017.4.17", "python-dateutil>=2.1", "six>=1.10", "urllib3>=1.23"]
4641

4742
here = os.path.abspath(os.path.dirname(__file__))
4843

@@ -61,8 +56,17 @@
6156
"Intended Audience :: Developers",
6257
"Topic :: Software Development",
6358
"License :: OSI Approved :: MIT License",
59+
"Operating System :: OS Independent",
6460
"Programming Language :: Python :: 2",
6561
"Programming Language :: Python :: 3",
62+
"Programming Language :: Python :: 2.7",
63+
"Programming Language :: Python :: 3.5",
64+
"Programming Language :: Python :: 3.6",
65+
"Programming Language :: Python :: 3.7",
66+
"Programming Language :: Python :: 3.8",
67+
"Programming Language :: Python :: 3.9",
68+
"Programming Language :: Python :: 3.10",
69+
"Programming Language :: Python :: 3.11",
6670
],
6771
keywords=[
6872
"Barcode-Scan",
@@ -177,7 +181,7 @@
177181
"Standard2of5",
178182
"SwissPostParcel",
179183
"UpcaGs1Code128Coupon",
180-
"UpcaGs1DatabarCoupon"
184+
"UpcaGs1DatabarCoupon",
181185
],
182186
install_requires=REQUIRES,
183187
packages=find_packages(exclude=["tests"]),

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pytest
22
pytest-cov
33
mock; python_version < "3"
44
black; python_version > "3.7"
5+
check-python-versions; python_version > "3.7"

tests/test_barcode_api.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def setUpClass(cls):
3535
# noinspection PyUnresolvedReferences
3636
cls.api = BarcodeApi(api_client=cls.api_client)
3737
cls.temp_folder_path = "BarcodeTests/%s" % uuid.uuid4()
38+
cls.test_put_barcode_generate_filename = "test_put_barcode_generate_file.png"
3839

3940
def test_get_barcode_generate(self):
4041
"""Test case for get_barcode_generate
@@ -109,27 +110,31 @@ def test_put_barcode_generate_file(self):
109110
110111
Generate barcode and save on server (from query params or from file with json or xml content)
111112
"""
112-
filename = "test_put_barcode_generate_file.png"
113113

114114
response = self.api.put_barcode_generate_file(
115-
filename, self.GENERATED_BARCODE_TYPE, self.GENERATED_BARCODE_TEXT, folder=self.temp_folder_path
115+
self.test_put_barcode_generate_filename,
116+
self.GENERATED_BARCODE_TYPE,
117+
self.GENERATED_BARCODE_TEXT,
118+
folder=self.temp_folder_path,
116119
)
117120

118121
self.assertGreater(response.file_size, 0)
119122
self.assertGreater(response.image_width, 0)
120123
self.assertGreater(response.image_height, 0)
121124

122-
return filename
123-
124125
def test_put_barcode_recognize_from_body(self):
125126
"""Test case for put_barcode_recognize_from_body
126127
127128
Recognition of a barcode from file on server with parameters in body.
128129
"""
129-
filename = self.test_put_barcode_generate_file()
130+
131+
# Ensure file self.test_put_barcode_generate_filename generated
132+
self.test_put_barcode_generate_file()
130133

131134
response = self.api.put_barcode_recognize_from_body(
132-
filename, ReaderParams(preset=PresetType.HIGHPERFORMANCE), folder=self.temp_folder_path
135+
self.test_put_barcode_generate_filename,
136+
ReaderParams(preset=PresetType.HIGHPERFORMANCE),
137+
folder=self.temp_folder_path,
133138
)
134139

135140
self.assertEqual(1, len(response.barcodes))

0 commit comments

Comments
 (0)