Browse Source

Use Flake8 code checker as part of running automated tests.

tags/1.2.7
Dan Helfman 1 year ago
parent
commit
56ad1d164a
18 changed files with 24 additions and 27 deletions
  1. +1
    -1
      NEWS
  2. +3
    -2
      README.md
  3. +1
    -1
      borgmatic/borg/check.py
  4. +0
    -1
      borgmatic/commands/convert_config.py
  5. +1
    -3
      borgmatic/commands/generate_config.py
  6. +1
    -1
      borgmatic/config/convert.py
  7. +0
    -1
      borgmatic/config/generate.py
  8. +0
    -2
      borgmatic/config/validate.py
  9. +2
    -4
      borgmatic/tests/integration/commands/test_borgmatic.py
  10. +0
    -1
      borgmatic/tests/integration/config/test_validate.py
  11. +2
    -1
      borgmatic/tests/unit/borg/test_check.py
  12. +5
    -4
      borgmatic/tests/unit/borg/test_create.py
  13. +2
    -2
      borgmatic/tests/unit/borg/test_extract.py
  14. +0
    -1
      borgmatic/tests/unit/borg/test_info.py
  15. +0
    -1
      borgmatic/tests/unit/borg/test_list.py
  16. +0
    -1
      borgmatic/tests/unit/commands/test_borgmatic.py
  17. +1
    -0
      test_requirements.txt
  18. +5
    -0
      tox.ini

+ 1
- 1
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

+ 3
- 2
README.md 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

+ 1
- 1
borgmatic/borg/check.py 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.

+ 0
- 1
borgmatic/commands/convert_config.py View File

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


+ 1
- 3
borgmatic/commands/generate_config.py 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'

+ 1
- 1
borgmatic/config/convert.py 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()

+ 0
- 1
borgmatic/config/generate.py View File

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

from ruamel import yaml

+ 0
- 2
borgmatic/config/validate.py View File

@@ -1,6 +1,4 @@
import logging
import sys
import warnings

import pkg_resources
import pykwalify.core

+ 2
- 4
borgmatic/tests/integration/commands/test_borgmatic.py 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



+ 0
- 1
borgmatic/tests/integration/config/test_validate.py View File

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

from flexmock import flexmock
import pytest

+ 2
- 1
borgmatic/tests/unit/borg/test_check.py View File

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

from flexmock import flexmock
import pytest

+ 5
- 4
borgmatic/tests/unit/borg/test_create.py 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


+ 2
- 2
borgmatic/tests/unit/borg/test_extract.py 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



+ 0
- 1
borgmatic/tests/unit/borg/test_info.py View File

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

from flexmock import flexmock


+ 0
- 1
borgmatic/tests/unit/borg/test_list.py View File

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

from flexmock import flexmock


+ 0
- 1
borgmatic/tests/unit/commands/test_borgmatic.py View File

@@ -2,7 +2,6 @@ import json
import sys

from flexmock import flexmock
import pytest

from borgmatic.commands import borgmatic


+ 1
- 0
test_requirements.txt 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

+ 5
- 0
tox.ini 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=*.*/*

Loading…
Cancel
Save