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
* 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
* 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.
borgmatic code uses the [Black](https://black.readthedocs.io/en/stable/) code
formatter, so some additional code style requirements will be enforced as
well. See the Black documentation for more information.
formatter and [Flake8](http://flake8.pycqa.org/en/latest/) code checker, so
certain code style requirements will be enforced when running automated tests.
See the Black and Flake8 documentation for more information.
### Development

View File

@ -84,7 +84,7 @@ def check_archives(
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.
If there are no consistency checks to run, skip running them.

View File

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

View File

@ -1,9 +1,7 @@
from argparse import ArgumentParser
import os
from subprocess import CalledProcessError
import sys
from borgmatic.config import convert, generate, validate
from borgmatic.config import generate, validate
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):
if excludes_filename != None:
if excludes_filename is not None:
raise LegacyExcludesFilenamePresent()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
import logging, sys
import logging
import sys
from flexmock import flexmock
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

View File

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

View File

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

View File

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

View File

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

View File

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