Skip to content

Commit

Permalink
Merge 1c1e3c6 into 283c4cb
Browse files Browse the repository at this point in the history
  • Loading branch information
micahjohnson150 committed Oct 30, 2021
2 parents 283c4cb + 1c1e3c6 commit 2448095
Show file tree
Hide file tree
Showing 15 changed files with 999 additions and 1,136 deletions.
147 changes: 74 additions & 73 deletions .github/workflows/unittest.yml
@@ -1,73 +1,74 @@
name: Unittest, flake8

# Run action on pull requests
on:
pull_request:
branches: [master]

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install flake8
- name: Lint with flake8
run: |
flake8 inicheck
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install coverage coveralls PyYAML
python3 -m pip install -r requirements.txt
- name: Run coverage
run: |
make coverage
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

unittest:
needs: [flake8, coverage]
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
- name: Run unittests
run: python3 -m unittest -v
name: Unittest, flake8

# Run action on pull requests
on:
pull_request:
branches: [master]

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install flake8
- name: Lint with flake8
run: |
flake8 inicheck
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install coverage coveralls PyYAML pytest
python3 -m pip install -r requirements.txt
- name: Run coverage
run: |
make coverage
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

unittest:
needs: [flake8, coverage]
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install pytest
- name: Run unittests
run: python3 -m pytest -v
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -53,8 +53,8 @@ lint: ## check style with isort and pep8
test: ## run tests quickly with the default Python
py.test

coverage: ## run coverage and submit
coverage run --source inicheck setup.py test
coverage: ## check code coverage quickly with the default Python
coverage run --source inicheck -m pytest
coverage report --fail-under=80

coveralls: coverage ## run coveralls
Expand Down
3 changes: 3 additions & 0 deletions inicheck/config.py
Expand Up @@ -9,6 +9,9 @@
from .iniparse import read_config
from .utilities import get_relative_to_cfg, mk_lst

# Unused import required for get_checkers to work.
from . import checkers as checkers_module # noqa

DEBUG = False
FULL_DEBUG = False

Expand Down
5 changes: 5 additions & 0 deletions inicheck/entries.py
Expand Up @@ -187,3 +187,8 @@ def __init__(self, name=None, parseable_line=None):
# Allow none should always be a bool
if str(self.allow_none).lower() == 'false':
self.allow_none = False
elif str(self.allow_none).lower() == 'true':
self.allow_none = True
else:
raise ValueError('Unrecognized allow_none in config entry named {}'
''.format(self.name))
17 changes: 9 additions & 8 deletions requirements_dev.txt
@@ -1,8 +1,9 @@
-r requirements.txt
autopep8
coverage==4.5.4
coveralls==1.11.1
isort==4.3.21
sphinx-rtd-theme==0.4.3
sphinx==1.8.5
sphinxcontrib-apidoc==0.3.0
-r requirements.txt
autopep8
coverage==4.5.4
coveralls==1.11.1
isort==4.3.21
sphinx-rtd-theme==0.4.3
sphinx==1.8.5
sphinxcontrib-apidoc==0.3.0
pytest==6.0.2
51 changes: 51 additions & 0 deletions tests/conftest.py
@@ -0,0 +1,51 @@
from os.path import join, dirname, abspath
from pathlib import Path
from inicheck.tools import get_user_config

import pytest

TEST_ROOT = dirname(abspath(__file__))


@pytest.fixture(scope='session', autouse=True)
def test_config_dir():
return Path(TEST_ROOT).joinpath('test_configs')


@pytest.fixture(scope='session', autouse=True)
def full_config_ini(test_config_dir):
return join(test_config_dir, "full_config.ini")


@pytest.fixture(scope='session', autouse=True)
def base_config_ini(test_config_dir):
return join(test_config_dir, "base_cfg.ini")


@pytest.fixture(scope='session', autouse=True)
def old_smrf_config_ini(test_config_dir):
return join(test_config_dir, "old_smrf_config.ini")


@pytest.fixture(scope='session', autouse=True)
def changelog_ini(test_config_dir):
return join(test_config_dir, "changelog.ini")


@pytest.fixture(scope='session', autouse=True)
def core_ini(test_config_dir):
return join(test_config_dir, "CoreConfig.ini")


@pytest.fixture(scope='session', autouse=True)
def recipes_ini(test_config_dir):
return join(test_config_dir, "recipes.ini")


@pytest.fixture(scope='session', autouse=True)
def master_ini(core_ini, recipes_ini):
return [core_ini, recipes_ini]

@pytest.fixture(scope='session', autouse=True)
def full_ucfg(full_config_ini, master_ini):
return get_user_config(full_config_ini, master_files=master_ini)
18 changes: 4 additions & 14 deletions tests/test_changes.py
Expand Up @@ -8,30 +8,20 @@
"""

import os
import unittest

from inicheck.changes import ChangeLog
from inicheck.config import MasterConfig, UserConfig


class TestChanges(unittest.TestCase):
class TestChanges():

def test_valid_syntax(self):
def test_valid_syntax(self, master_ini, changelog_ini):
"""
Test we can detect valid syntax
"""
base = os.path.dirname(__file__)
master = os.path.join(base, 'test_configs/CoreConfig.ini')
recipes = os.path.join(base, 'test_configs/recipes.ini')
mcfg = MasterConfig(path=[master, recipes])
cf = os.path.join(base, 'test_configs/changelog.ini')
mcfg = MasterConfig(path=master_ini)
try:
c = ChangeLog(paths=cf, mcfg=mcfg)
c = ChangeLog(paths=changelog_ini, mcfg=mcfg)
assert True
except Exception:
assert False


if __name__ == '__main__':
import sys
sys.exit(unittest.main())

0 comments on commit 2448095

Please sign in to comment.