diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcbccfc..45a8857 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,12 +31,11 @@ jobs: pip install black==22.6.0 pip install pytest pip install PyYAML - pip install setuptools - name: validate-style run: | make validate-style - name: Tests - run: | + run: pytest tests/ diff --git a/setup.py b/setup.py index d1375fc..18fd15b 100644 --- a/setup.py +++ b/setup.py @@ -5,8 +5,8 @@ version="1.0.2", packages=find_packages(exclude=["tests*"]), install_requires=["antlr4-python3-runtime>=4.10"], - tests_require=["pytest", "PyYAML"], - setup_requires=["flake8", "black"], + tests_require=["pytest", "PyYAML", "setuptools"], + setup_requires=["flake8", "black", "setuptools"], entry_points={ "console_scripts": [ "promformat = promformat.__main__:main", diff --git a/tests/test_formatter.py b/tests/test_formatter.py index 2601991..0f7bad6 100644 --- a/tests/test_formatter.py +++ b/tests/test_formatter.py @@ -1,7 +1,7 @@ +from importlib.resources import files from random import randint import antlr4 -import pkg_resources import yaml import pytest from antlr4 import CommonTokenStream @@ -11,7 +11,6 @@ import hashlib import os -import pkg_resources import yaml import pytest @@ -20,8 +19,8 @@ def get_rules(): - rule_path = pkg_resources.resource_filename("tests.resources", "test-promql.yaml") - with open(rule_path) as f: + rule_path = files("tests.resources") / "test-promql.yaml" + with open(str(rule_path)) as f: data = yaml.safe_load(f) for group in data["groups"]: for service in group["services"]: @@ -117,7 +116,7 @@ def test_comments(query: str): ], ) def test_formatter(query, file_name): - rule_path = pkg_resources.resource_filename("tests.resources", "formatted") + rule_path = str(files("tests.resources") / "formatted") path = os.path.join(rule_path, file_name) with open(path) as f: expected_formatting = f.read()