Skip to content

Commit a86137a

Browse files
authored
Test by GitHub Actions (#212)
* GitHub Action for nosetests * Allow flexible version string * Fix the mock's return value
1 parent 1bd1450 commit a86137a

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

.github/workflows/nosetests.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: nosetests
5+
6+
on:
7+
push:
8+
branches: [ stable ]
9+
pull_request:
10+
branches: [ stable ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python 3.8
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.8
23+
- name: Install D compiler
24+
uses: dlang-community/setup-dlang@v1
25+
with:
26+
compiler: dmd-latest
27+
- name: Install other compilers
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install nim mono-complete
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install flake8 autopep8
35+
pip install codecov nose
36+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
37+
pip install .
38+
- name: Lint with flake8
39+
run: |
40+
flake8 --ignore=E501,W503,W605 --exclude=atcodertools/tools/templates/,tests/resources/test_codegen/ atcodertools tests
41+
autopep8 -r . --exclude 'default_template.py,test_codegen' --diff | tee check_autopep8
42+
test ! -s check_autopep8
43+
- name: Test with nosetests
44+
run: |
45+
atcoder-tools gen arc050 --without-login
46+
nosetests tests --exe -v --with-coverage --cover-package=atcodertools
47+
codecov

tests/test_codegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def _compile_and_run(self, lang, format, template_file, expected_generated_code_
240240
)
241241
code = lang.default_code_generator(args)
242242
# to remove version strings from test resources
243-
code = re.sub(r'Generated by \d+.\d+.\d+', 'Generated by x.y.z', code)
243+
code = re.sub(r'Generated by \d+(\.\d+)+', 'Generated by x.y.z', code)
244244
self.compare_two_texts_ignoring_trailing_spaces(
245245
load_text_file(expected_generated_code_file), code)
246246
create_code(code, code_file)

tests/test_envgen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from os.path import relpath
77
from logging import getLogger
88

9-
from atcodertools.client.atcoder import AtCoderClient
9+
from atcodertools.client.atcoder import AtCoderClient, PageNotFoundError
1010
from atcodertools.codegen.code_style_config import CodeStyleConfig
1111
from atcodertools.config.config import Config
1212
from atcodertools.config.etc_config import EtcConfig
@@ -80,7 +80,7 @@ def test_backup(self):
8080
@mock.patch('time.sleep')
8181
def test_prepare_contest_aborts_after_max_retry_attempts(self, mock_sleep):
8282
mock_client = mock.Mock(spec=AtCoderClient)
83-
mock_client.download_problem_list.return_value = []
83+
mock_client.download_problem_list.side_effect = PageNotFoundError
8484
self.assertRaises(
8585
EnvironmentInitializationError,
8686
prepare_contest,

0 commit comments

Comments
 (0)