Skip to content

Commit 60e8b67

Browse files
committed
fluent.syntax tests and linting on gh actions
Making the test runner actually use the python you run it with. Then, add gh-actions test automation. As I saw a deprecation warning on master, I went in and fixed the tests, including flake8. And thus I switched on flake8 for all of fluent.syntax.
1 parent 8240a48 commit 60e8b67

12 files changed

Lines changed: 19 additions & 39 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: lint
2727
working-directory: ./fluent.syntax
2828
run: |
29-
flake8 fluent
29+
flake8
3030
3131
runtime:
3232
name: flake8 runtime

.github/workflows/syntax-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ jobs:
1414
unit:
1515
name: Syntax unit tests
1616
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3]
1720
steps:
1821
- uses: actions/checkout@v2
1922
- uses: actions/setup-python@v2
2023
with:
21-
python-version: 3.7
24+
python-version: ${{ matrix.python-version }}
2225
- name: Install dependencies
2326
working-directory: ./fluent.syntax
2427
run: |

fluent.runtime/runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
if args.coverage:
2626
cmd = ["-m", "coverage", "run"] + cmd
2727

28-
cmd.insert(0, "python")
28+
cmd.insert(0, sys.executable)
2929

3030
sys.exit(subprocess.call(cmd))

fluent.syntax/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
# These should also be duplicated in tox.ini and ../.travis.yml
2222
tests_require=['six'],
2323
test_suite='tests.syntax'
24-
)
24+
)

fluent.syntax/tests/syntax/test_ast_json.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from __future__ import unicode_literals
22
import unittest
3-
import sys
4-
5-
sys.path.append('.')
63

74
from tests.syntax import dedent_ftl
85
from fluent.syntax.ast import from_json

fluent.syntax/tests/syntax/test_entry.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from __future__ import unicode_literals
22
import unittest
3-
import sys
4-
5-
sys.path.append(".")
63

74
from tests.syntax import dedent_ftl
85
from fluent.syntax.ast import from_json
@@ -138,7 +135,6 @@ def test_ignore_all_valid_comments(self):
138135
message = self.parser.parse_entry(dedent_ftl(input))
139136
self.assertEqual(message.to_json(), output)
140137

141-
142138
def test_do_not_ignore_invalid_comments(self):
143139
input = """\
144140
# Attached Comment

fluent.syntax/tests/syntax/test_equals.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from __future__ import unicode_literals
22
import unittest
3-
import sys
4-
5-
sys.path.append('.')
63

74
from tests.syntax import dedent_ftl
85
from fluent.syntax.parser import FluentParser

fluent.syntax/tests/syntax/test_reference.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
from six import with_metaclass
33

44
import os
5-
import sys
65
import json
76
import codecs
87
import unittest
98

10-
sys.path.append('.')
11-
12-
from fluent.syntax import parse, ast as ftl
9+
from fluent.syntax import parse
1310

1411

1512
def read_file(path):

fluent.syntax/tests/syntax/test_serializer.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from __future__ import unicode_literals
22
import unittest
3-
import sys
4-
5-
sys.path.append('.')
63

4+
import six
75
from tests.syntax import dedent_ftl
86
from fluent.syntax import FluentParser, FluentSerializer
97
from fluent.syntax.serializer import serialize_expression, serialize_variant_key
@@ -20,10 +18,10 @@ def pretty_ftl(text):
2018
def test_invalid_resource(self):
2119
serializer = FluentSerializer()
2220

23-
with self.assertRaisesRegexp(Exception, 'Unknown resource type'):
21+
with six.assertRaisesRegex(self, Exception, 'Unknown resource type'):
2422
serializer.serialize(None)
2523

26-
with self.assertRaisesRegexp(Exception, 'Unknown resource type'):
24+
with six.assertRaisesRegex(self, Exception, 'Unknown resource type'):
2725
serializer.serialize(object())
2826

2927
def test_simple_message(self):
@@ -430,10 +428,10 @@ def pretty_expr(text):
430428
return serialize_expression(expr)
431429

432430
def test_invalid_expression(self):
433-
with self.assertRaisesRegexp(Exception, 'Unknown expression type'):
431+
with six.assertRaisesRegex(self, Exception, 'Unknown expression type'):
434432
serialize_expression(None)
435433

436-
with self.assertRaisesRegexp(Exception, 'Unknown expression type'):
434+
with six.assertRaisesRegex(self, Exception, 'Unknown expression type'):
437435
serialize_expression(object())
438436

439437
def test_string_expression(self):
@@ -491,10 +489,10 @@ def pretty_variant_key(text, index):
491489
return serialize_variant_key(variants[index].key)
492490

493491
def test_invalid_expression(self):
494-
with self.assertRaisesRegexp(Exception, 'Unknown variant key type'):
492+
with six.assertRaisesRegex(self, Exception, 'Unknown variant key type'):
495493
serialize_variant_key(None)
496494

497-
with self.assertRaisesRegexp(Exception, 'Unknown variant key type'):
495+
with six.assertRaisesRegex(self, Exception, 'Unknown variant key type'):
498496
serialize_variant_key(object())
499497

500498
def test_identifiers(self):

fluent.syntax/tests/syntax/test_stream.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import unittest
2-
import sys
3-
4-
sys.path.append('.')
52

63
from fluent.syntax.stream import ParserStream
74

5+
86
class TestParserStream(unittest.TestCase):
97

108
def test_next(self):
@@ -161,7 +159,3 @@ def test_reset_peek(self):
161159

162160
self.assertEqual('d', ps.peek())
163161
self.assertEqual(None, ps.peek())
164-
165-
166-
if __name__ == '__main__':
167-
unittest.main()

0 commit comments

Comments
 (0)