Skip to content

Commit

Permalink
fix if tests are in own module
Browse files Browse the repository at this point in the history
  • Loading branch information
joelb123 committed Jun 4, 2020
1 parent 85c0ac2 commit 9ddeced
Show file tree
Hide file tree
Showing 10 changed files with 884 additions and 152 deletions.
74 changes: 74 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: check-yaml
- id: check-toml
- id: fix-encoding-pragma
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: local
hooks:
- id: flynt
name: flynt
entry: flynt
args: [--fail-on-change]
types: [python]
language: python
additional_dependencies:
- flynt
#- repo: local
# hooks:
# - id: isort
# name: run isort
# entry: isort
# args: [-yq]
# language: python
# additional_dependencies:
# - isort
# - toml
#- repo: local
# hooks:
# - id: tests
# name: run tests
# entry: pytest -s
# language: python
# types: [python]
# stages: [push]
# additional_dependencies:
# - pytest
# - pytest-cov
#- repo: local
# hooks:
# - id: pydocstyle
# name: pydocstyle
# description: 'Check for adherence to python docstring conventions.'
# entry: pydocstyle
# language: python
# types: [python]
# additional_dependencies:
# - pydocstyle
#- repo: https://github.com/pre-commit/mirrors-pylint
# rev: v2.5.2
# hooks:
# - id: pylint
#- repo: local
# hooks:
# - id: bandit
# name: bandit
# description: 'Find common security issues in Python code'
# entry: bandit
# language: python
# types: [python]
#- repo: local
# hooks:
# - id: poetry-dynamic-versioning
# name: update version from SCM tags
# entry: poetry-dynamic-versioning
# always_run: true
# exclude: .*
# language: python
# additional_dependencies:
# - poetry-dynamic-versioning
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
sudo: false
language: python
python:
- '3.7'
- '3.8'
before_install:
- pip install poetry
install:
- poetry install -v
script:
- poetry run pytest -s
- poetry run nox -s tests
after_success:
- bash <(curl -s https://codecov.io/bash) -X gcov
47 changes: 47 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
"""Nox testing environment defs."""
# cribbed from https://cjolowicz.github.io/posts/hypermodern-python-03-linting/

# standard library imports
import tempfile

# third-party imports
import nox

CODE_LOCATIONS = (
"pytest_datadir_mgr",
"tests",
"noxfile.py",
)


def install_with_constraints(session, *args, **kwargs):
"""Get dependencies from poetry."""
with tempfile.NamedTemporaryFile() as requirements:
session.run(
"poetry",
"export",
"--dev",
"--format=requirements.txt",
f"--output={requirements.name}",
external=True,
)
session.install(f"--constraint={requirements.name}", *args, **kwargs)


@nox.session(python=["3.8"])
def tests(session):
"""Run tests with pytest and pytest-cov."""
args = session.posargs or ["--cov"]
session.run("poetry", "install", "--no-dev", external=True)
install_with_constraints(session, "coverage[toml]", "pytest", "pytest-cov")
session.run("pytest", *args)


@nox.session(python=["3.8"])
def lint_pylint(session):
"""Run lint on all code."""
args = session.posargs or CODE_LOCATIONS
session.run("poetry", "install", "--no-dev", external=True)
install_with_constraints(session, "pylint", "nox")
session.run("pylint", *args)

0 comments on commit 9ddeced

Please sign in to comment.