Use Flake8 code checker as part of running automated tests.

This commit is contained in:
Dan Helfman 2018-09-29 23:15:18 -07:00
parent 3cce18919c
commit 56ad1d164a
18 changed files with 24 additions and 27 deletions

2
NEWS
View file

@ -1,5 +1,5 @@
1.2.7.dev0 1.2.7.dev0
* Use Black code formatter as part of running automated tests. * Use Black code formatter and Flake8 code checker as part of running automated tests.
1.2.6 1.2.6
* Fix generated configuration to also include a "keep_daily" value so pruning works out of the * Fix generated configuration to also include a "keep_daily" value so pruning works out of the

View file

@ -383,8 +383,9 @@ the following deviations from it:
indentation with an opening delimeter. indentation with an opening delimeter.
borgmatic code uses the [Black](https://black.readthedocs.io/en/stable/) code borgmatic code uses the [Black](https://black.readthedocs.io/en/stable/) code
formatter, so some additional code style requirements will be enforced as formatter and [Flake8](http://flake8.pycqa.org/en/latest/) code checker, so
well. See the Black documentation for more information. certain code style requirements will be enforced when running automated tests.
See the Black and Flake8 documentation for more information.
### Development ### Development

View file

@ -84,7 +84,7 @@ def check_archives(
repository, storage_config, consistency_config, local_path='borg', remote_path=None repository, storage_config, consistency_config, local_path='borg', remote_path=None
): ):
''' '''
Given a local or remote repository path, a storage config dict, a consistency config dict, Given a local or remote repository path, a storage config dict, a consistency config dict,
and a local/remote commands to run, check the contained Borg archives for consistency. and a local/remote commands to run, check the contained Borg archives for consistency.
If there are no consistency checks to run, skip running them. If there are no consistency checks to run, skip running them.

View file

@ -1,6 +1,5 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import os import os
from subprocess import CalledProcessError
import sys import sys
import textwrap import textwrap

View file

@ -1,9 +1,7 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import os
from subprocess import CalledProcessError
import sys import sys
from borgmatic.config import convert, generate, validate from borgmatic.config import generate, validate
DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml' DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml'

View file

@ -109,5 +109,5 @@ Please remove the "--excludes" argument and run borgmatic again.'''
def guard_excludes_filename_omitted(excludes_filename): def guard_excludes_filename_omitted(excludes_filename):
if excludes_filename != None: if excludes_filename is not None:
raise LegacyExcludesFilenamePresent() raise LegacyExcludesFilenamePresent()

View file

@ -1,4 +1,3 @@
from collections import OrderedDict
import os import os
from ruamel import yaml from ruamel import yaml

View file

@ -1,6 +1,4 @@
import logging import logging
import sys
import warnings
import pkg_resources import pkg_resources
import pykwalify.core import pykwalify.core

View file

@ -1,5 +1,3 @@
import os
from flexmock import flexmock from flexmock import flexmock
import pytest import pytest
@ -13,7 +11,7 @@ def test_parse_arguments_with_no_arguments_uses_defaults():
parser = module.parse_arguments() parser = module.parse_arguments()
assert parser.config_paths == config_paths assert parser.config_paths == config_paths
assert parser.excludes_filename == None assert parser.excludes_filename is None
assert parser.verbosity is 0 assert parser.verbosity is 0
assert parser.json is False assert parser.json is False
@ -44,7 +42,7 @@ def test_parse_arguments_with_verbosity_flag_overrides_default():
parser = module.parse_arguments('--verbosity', '1') parser = module.parse_arguments('--verbosity', '1')
assert parser.config_paths == config_paths assert parser.config_paths == config_paths
assert parser.excludes_filename == None assert parser.excludes_filename is None
assert parser.verbosity == 1 assert parser.verbosity == 1

View file

@ -1,7 +1,6 @@
import io import io
import string import string
import sys import sys
import os
from flexmock import flexmock from flexmock import flexmock
import pytest import pytest

View file

@ -1,5 +1,6 @@
from subprocess import STDOUT from subprocess import STDOUT
import logging, sys import logging
import sys
from flexmock import flexmock from flexmock import flexmock
import pytest import pytest

View file

@ -1,4 +1,5 @@
import logging, os import logging
import os
from flexmock import flexmock from flexmock import flexmock
@ -45,9 +46,9 @@ def test_initialize_environment_without_configuration_should_not_set_environment
try: try:
os.environ = {} os.environ = {}
module.initialize_environment({}) module.initialize_environment({})
assert os.environ.get('BORG_PASSCOMMAND') == None assert os.environ.get('BORG_PASSCOMMAND') is None
assert os.environ.get('BORG_PASSPHRASE') == None assert os.environ.get('BORG_PASSPHRASE') is None
assert os.environ.get('BORG_RSH') == None assert os.environ.get('BORG_RSH') is None
finally: finally:
os.environ = orig_environ os.environ = orig_environ

View file

@ -1,9 +1,9 @@
import logging, sys import logging
import sys
from flexmock import flexmock from flexmock import flexmock
from borgmatic.borg import extract as module from borgmatic.borg import extract as module
from borgmatic.verbosity import VERBOSITY_SOME, VERBOSITY_LOTS
from borgmatic.tests.unit.test_verbosity import insert_logging_mock from borgmatic.tests.unit.test_verbosity import insert_logging_mock

View file

@ -1,5 +1,4 @@
import logging import logging
from collections import OrderedDict
from flexmock import flexmock from flexmock import flexmock

View file

@ -1,5 +1,4 @@
import logging import logging
from collections import OrderedDict
from flexmock import flexmock from flexmock import flexmock

View file

@ -2,7 +2,6 @@ import json
import sys import sys
from flexmock import flexmock from flexmock import flexmock
import pytest
from borgmatic.commands import borgmatic from borgmatic.commands import borgmatic

View file

@ -1,4 +1,5 @@
black==18.9b0 black==18.9b0
flake8==3.5.0
flexmock==0.10.2 flexmock==0.10.2
pykwalify==1.6.1 pykwalify==1.6.1
pytest==3.8.1 pytest==3.8.1

View file

@ -8,8 +8,13 @@ deps=-rtest_requirements.txt
commands = commands =
py.test --cov-report term-missing:skip-covered --cov=borgmatic borgmatic [] py.test --cov-report term-missing:skip-covered --cov=borgmatic borgmatic []
black --skip-string-normalization --line-length 100 --check . black --skip-string-normalization --line-length 100 --check .
flake8 .
[testenv:black] [testenv:black]
basepython=python3.7 basepython=python3.7
commands = commands =
black --skip-string-normalization --line-length 100 . black --skip-string-normalization --line-length 100 .
[flake8]
ignore=E501,W503
exclude=*.*/*