From c8a7eb8f901adea9d7841f7c1bff71f6fc3f5c0d Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Sun, 15 Sep 2019 15:09:19 +0300 Subject: [PATCH] Converts test to pytest, nose is dead --- .gitignore | 1 + .pylintrc | 514 +++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 17 +- test/run_dump.sh | 5 +- test/test_api.py | 182 +++++++++--------- test/test_crypto.py | 89 ++++----- test/test_format.py | 101 +++++----- test/test_hashing.py | 50 +++-- test/test_korrupt.py | 2 +- test/test_reading.py | 39 ++-- test/test_seek.py | 6 +- tox.ini | 91 +++++---- 12 files changed, 801 insertions(+), 296 deletions(-) create mode 100644 .pylintrc rewrite test/test_crypto.py (60%) rewrite tox.ini (79%) diff --git a/.gitignore b/.gitignore index 60fbe99..a3fb827 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ build tmp doc/_build doc/html +cover diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..65e5229 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,514 @@ +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-whitelist= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS,tmp,dist + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Specify a configuration file. +#rcfile= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=bad-continuation, + bad-whitespace, + bare-except, + broad-except, + consider-using-in, + consider-using-ternary, + fixme, + global-statement, + invalid-name, + missing-docstring, + no-else-raise, + no-else-return, + no-self-use, + trailing-newlines, + unused-argument, + unused-variable, + useless-object-inheritance, + protected-access, + ungrouped-imports, + chained-comparison, + len-as-condition, + redefined-builtin, + unnecessary-pass + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +#msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=no + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=10 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit + + +[LOGGING] + +# Format style used to check logging format string. `old` means using % +# formatting, while `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package.. +#spelling-dict=en_US + +# List of comma separated words that should not be checked. +spelling-ignore-words=usr,bin,env + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file=.local.dict + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[BASIC] + +# Naming style matching correct argument names. +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. +#argument-rgx= + +# Naming style matching correct attribute names. +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. +#class-attribute-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _ + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. +#variable-rgx= + + +[STRING] + +# This flag controls whether the implicit-str-concat-in-sequence should +# generate a warning on implicit string concatenation in sequences defined over +# several lines. +check-str-concat-over-line-jumps=no + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format=LF + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=160 + +# Maximum number of lines in a module. +max-module-lines=10000 + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma, + dict-separator + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=cls + + +[DESIGN] + +# Maximum number of arguments for function / method. +max-args=15 + +# Maximum number of attributes for a class (see R0902). +max-attributes=17 + +# Maximum number of boolean expressions in an if statement. +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=50 + +# Maximum number of locals for function / method body. +max-locals=45 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=420 + +# Maximum number of return / yield for function / method body. +max-returns=16 + +# Maximum number of statements in function / method body. +max-statements=150 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=0 + + +[IMPORTS] + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules=optparse,tkinter.tix + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled). +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled). +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "BaseException, Exception". +overgeneral-exceptions=BaseException, + Exception diff --git a/Makefile b/Makefile index 8bba3cd..50497ce 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,19 @@ +VER := $(shell python3 setup.py --version) +TGZ = dist/rarfile-$(VER).tar.gz + prefix = /usr/local all: pyflakes3 rarfile.py - tox + tox -e lint + tox -e py36-cryptography + tox -e py37 install: python setup.py install --prefix=$(prefix) -tgz: clean - python setup.py sdist +tgz: clean $(TGZ) clean: rm -rf __pycache__ build dist @@ -25,8 +29,11 @@ toxclean: clean rbuild: curl -X POST https://readthedocs.org/build/6715 -upload: - python setup.py sdist upload +$(TGZ): + python3 setup.py sdist + +upload: $(TGZ) + twine upload $(TGZ) ack: for fn in test/files/*.py27; do \ diff --git a/test/run_dump.sh b/test/run_dump.sh index 59d29dd..3e9aa88 100755 --- a/test/run_dump.sh +++ b/test/run_dump.sh @@ -35,7 +35,10 @@ for f in test/files/*.rar; do fi echo "#### $py ####" >> "$diffs" diff -uw "$f.exp" "$f.$tag" >> "$diffs" - result=1 + case "$f" in + *-hpsw.rar) ;; + *) result=1;; + esac fi done diff --git a/test/test_api.py b/test/test_api.py index a6ffa49..1fb2483 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -1,10 +1,10 @@ """API tests. """ -import sys + import io import os -from nose.tools import * +import pytest import rarfile @@ -15,36 +15,37 @@ if rarfile._have_pathlib: # test start # -@raises(NotImplementedError) def test_bad_arc_mode_w(): - rarfile.RarFile('test/files/rar3-comment-plain.rar', 'w') + with pytest.raises(NotImplementedError): + rarfile.RarFile('test/files/rar3-comment-plain.rar', 'w') -@raises(NotImplementedError) def test_bad_arc_mode_rb(): - rarfile.RarFile('test/files/rar3-comment-plain.rar', 'rb') + with pytest.raises(NotImplementedError): + rarfile.RarFile('test/files/rar3-comment-plain.rar', 'rb') -@raises(ValueError) def test_bad_errs(): - rarfile.RarFile('test/files/rar3-comment-plain.rar', 'r', errors='foo') + with pytest.raises(ValueError): + rarfile.RarFile('test/files/rar3-comment-plain.rar', 'r', errors='foo') -@raises(NotImplementedError) def test_bad_open_mode_w(): rf = rarfile.RarFile('test/files/rar3-comment-plain.rar') - rf.open('qwe', 'w') + with pytest.raises(NotImplementedError): + rf.open('qwe', 'w') -@raises(rarfile.PasswordRequired) def test_bad_open_psw(): rf = rarfile.RarFile('test/files/rar3-comment-psw.rar') - rf.open('file1.txt') + with pytest.raises(rarfile.PasswordRequired): + rf.open('file1.txt') -@raises(ValueError) def test_bad_filelike(): - rarfile.is_rarfile(bytearray(10)) + with pytest.raises(ValueError): + rarfile.is_rarfile(bytearray(10)) def test_open_psw_late_rar3(): rf = rarfile.RarFile('test/files/rar3-comment-psw.rar') - rf.open('file1.txt', 'r', 'password').read() - rf.open('file1.txt', 'r', u'password').read() + d1 = rf.open('file1.txt', 'r', 'password').read() + d2 = rf.open('file1.txt', 'r', u'password').read() + assert d1 == d2 def test_open_psw_late_rar5(): rf = rarfile.RarFile('test/files/rar5-psw.rar') @@ -66,42 +67,46 @@ def test_read_psw_late_rar5(): rf.read('stest1.txt', 'password') rf.read('stest1.txt', u'password') -@raises(rarfile.BadRarFile) # needs better error def test_open_psw_late(): rf = rarfile.RarFile('test/files/rar5-psw.rar') - rf.read('stest1.txt', 'password222') + with pytest.raises(rarfile.BadRarFile): + rf.read('stest1.txt', 'password222') if rarfile._have_pathlib: def test_create_from_pathlib_path(): # Make sure we can open both relative and absolute Paths rarfile.RarFile(Path('test/files/rar5-psw.rar')) rarfile.RarFile(Path('test/files/rar5-psw.rar').resolve()) - + def test_detection(): - eq_(rarfile.is_rarfile('test/files/ctime4.rar.exp'), False) - eq_(rarfile.is_rarfile('test/files/ctime4.rar'), True) - eq_(rarfile.is_rarfile('test/files/rar5-crc.rar'), True) + assert rarfile.is_rarfile('test/files/ctime4.rar.exp') is False + assert rarfile.is_rarfile('test/files/ctime4.rar') is True + assert rarfile.is_rarfile('test/files/rar5-crc.rar') is True if rarfile._have_pathlib: - eq_(rarfile.is_rarfile(Path('test/files/rar5-crc.rar')), True) + assert rarfile.is_rarfile(Path('test/files/rar5-crc.rar')) is True -@raises(rarfile.BadRarFile) def test_signature_error(): - rarfile.RarFile('test/files/ctime4.rar.exp') + with pytest.raises(rarfile.BadRarFile): + rarfile.RarFile('test/files/ctime4.rar.exp') -@raises(rarfile.BadRarFile) def test_signature_error_mem(): data = io.BytesIO(b'x'*40) - rarfile.RarFile(data) + with pytest.raises(rarfile.BadRarFile): + rarfile.RarFile(data) def test_with(): with rarfile.RarFile('test/files/rar5-crc.rar') as rf: + data = rf.read('stest1.txt') with rf.open('stest1.txt') as f: + dst = io.BytesIO() while 1: buf = f.read(7) if not buf: break + dst.write(buf) + assert dst.getvalue() == data def test_readline(): def load_readline(rf, fn): @@ -118,26 +123,14 @@ def test_readline(): rf = rarfile.RarFile('test/files/seektest.rar') v1 = load_readline(rf, 'stest1.txt') v2 = load_readline(rf, 'stest2.txt') - eq_(len(v1), 512) - eq_(v1, v2) - -_old_stdout = None -_buf_stdout = None - -def install_buf(): - global _old_stdout, _buf_stdout - _buf_stdout = io.StringIO() - _old_stdout = sys.stdout - sys.stdout = _buf_stdout - -def uninstall_buf(): - sys.stdout = _old_stdout + assert len(v1) == 512 + assert v1 == v2 -@with_setup(install_buf, uninstall_buf) -def test_printdir(): +def test_printdir(capsys): rf = rarfile.RarFile('test/files/seektest.rar') rf.printdir() - eq_(_buf_stdout.getvalue(), u'stest1.txt\nstest2.txt\n') + res = capsys.readouterr() + assert res.out == u'stest1.txt\nstest2.txt\n' def test_testrar(): rf = rarfile.RarFile('test/files/seektest.rar') @@ -148,70 +141,63 @@ def test_testrar_mem(): rf = rarfile.RarFile(io.BytesIO(arc)) rf.testrar() -def clean_extract_dirs(): - for dn in ['tmp/extract1', 'tmp/extract2', 'tmp/extract3']: - for fn in ['stest1.txt', 'stest2.txt']: - try: - os.unlink(os.path.join(dn, fn)) - except OSError: - pass - try: - os.rmdir(dn) - except OSError: - pass - -@with_setup(clean_extract_dirs, clean_extract_dirs) -def test_extract(): - os.makedirs('tmp/extract1') - os.makedirs('tmp/extract2') - os.makedirs('tmp/extract3') +def test_extract(tmp_path): + ex1 = tmp_path / "extract1" + ex2 = tmp_path / "extract2" + ex3 = tmp_path / "extract3" + os.makedirs(str(ex1)) + os.makedirs(str(ex2)) + os.makedirs(str(ex3)) rf = rarfile.RarFile('test/files/seektest.rar') - rf.extractall('tmp/extract1') - assert_true(os.path.isfile('tmp/extract1/stest1.txt')) - assert_true(os.path.isfile('tmp/extract1/stest2.txt')) + rf.extractall(str(ex1)) + assert os.path.isfile(str(ex1 / 'stest1.txt')) is True + assert os.path.isfile(str(ex1 / 'stest2.txt')) is True - rf.extract('stest1.txt', 'tmp/extract2') - assert_true(os.path.isfile('tmp/extract2/stest1.txt')) - assert_false(os.path.isfile('tmp/extract2/stest2.txt')) + rf.extract('stest1.txt', str(ex2)) + assert os.path.isfile(str(ex2 / 'stest1.txt')) is True + assert os.path.isfile(str(ex2 / 'stest2.txt')) is False inf = rf.getinfo('stest2.txt') - rf.extract(inf, 'tmp/extract3') - assert_false(os.path.isfile('tmp/extract3/stest1.txt')) - assert_true(os.path.isfile('tmp/extract3/stest2.txt')) + rf.extract(inf, str(ex3)) + assert os.path.isfile(str(ex3 / 'stest1.txt')) is False + assert os.path.isfile(str(ex3 / 'stest2.txt')) is True - rf.extractall('tmp/extract2', ['stest1.txt']) - assert_true(os.path.isfile('tmp/extract2/stest1.txt')) + rf.extractall(str(ex2), ['stest1.txt']) + assert os.path.isfile(str(ex2 / 'stest1.txt')) is True - rf.extractall('tmp/extract3', [rf.getinfo('stest2.txt')]) - assert_true(os.path.isfile('tmp/extract3/stest2.txt')) + rf.extractall(str(ex3), [rf.getinfo('stest2.txt')]) + assert os.path.isfile(str(ex3 / 'stest2.txt')) is True if rarfile._have_pathlib: - os.makedirs('tmp/extract1_pathlib') - rf.extractall(Path('tmp/extract1')) - assert_true(os.path.isfile('tmp/extract1/stest1.txt')) - assert_true(os.path.isfile('tmp/extract1/stest2.txt')) - -@with_setup(clean_extract_dirs, clean_extract_dirs) -def test_extract_mem(): - os.makedirs('tmp/extract1') - os.makedirs('tmp/extract2') - os.makedirs('tmp/extract3') + ex4 = tmp_path / "extract4" + os.makedirs(str(ex4)) + rf.extractall(ex4) + assert os.path.isfile(str(ex4 / 'stest1.txt')) is True + assert os.path.isfile(str(ex4 / 'stest2.txt')) is True + +def test_extract_mem(tmp_path): + ex1 = tmp_path / "extract11" + ex2 = tmp_path / "extract22" + ex3 = tmp_path / "extract33" + os.makedirs(str(ex1)) + os.makedirs(str(ex2)) + os.makedirs(str(ex3)) arc = open('test/files/seektest.rar', 'rb').read() rf = rarfile.RarFile(io.BytesIO(arc)) - rf.extractall('tmp/extract1') - assert_true(os.path.isfile('tmp/extract1/stest1.txt')) - assert_true(os.path.isfile('tmp/extract1/stest2.txt')) + rf.extractall(str(ex1)) + assert os.path.isfile(str(ex1 / 'stest1.txt')) is True + assert os.path.isfile(str(ex1 / 'stest2.txt')) is True - rf.extract('stest1.txt', 'tmp/extract2') - assert_true(os.path.isfile('tmp/extract2/stest1.txt')) - assert_false(os.path.isfile('tmp/extract2/stest2.txt')) + rf.extract('stest1.txt', str(ex2)) + assert os.path.isfile(str(ex2 / 'stest1.txt')) is True + assert os.path.isfile(str(ex2 / 'stest2.txt')) is False inf = rf.getinfo('stest2.txt') - rf.extract(inf, 'tmp/extract3') - assert_false(os.path.isfile('tmp/extract3/stest1.txt')) - assert_true(os.path.isfile('tmp/extract3/stest2.txt')) + rf.extract(inf, str(ex3)) + assert os.path.isfile(str(ex3 / 'stest1.txt')) is False + assert os.path.isfile(str(ex3 / 'stest2.txt')) is True def test_infocb(): infos = [] @@ -219,22 +205,22 @@ def test_infocb(): infos.append( (info.type, info.needs_password(), info.isdir(), info._must_disable_hack()) ) rf = rarfile.RarFile('test/files/seektest.rar', info_callback=info_cb) - eq_(infos, [ + assert infos == [ (rarfile.RAR_BLOCK_MAIN, False, False, False), (rarfile.RAR_BLOCK_FILE, False, False, False), (rarfile.RAR_BLOCK_FILE, False, False, False), - (rarfile.RAR_BLOCK_ENDARC, False, False, False)]) + (rarfile.RAR_BLOCK_ENDARC, False, False, False)] infos = [] rf = rarfile.RarFile('test/files/rar5-solid-qo.rar', info_callback=info_cb) - eq_(infos, [ + assert infos == [ (rarfile.RAR_BLOCK_MAIN, False, False, True), (rarfile.RAR_BLOCK_FILE, False, False, False), (rarfile.RAR_BLOCK_FILE, False, False, True), (rarfile.RAR_BLOCK_FILE, False, False, True), (rarfile.RAR_BLOCK_FILE, False, False, True), (rarfile.RAR_BLOCK_SUB, False, False, False), - (rarfile.RAR_BLOCK_ENDARC, False, False, False)]) + (rarfile.RAR_BLOCK_ENDARC, False, False, False)] def install_alt_tool(): rarfile.ORIG_UNRAR_TOOL = 'x_unrar_missing' @@ -249,7 +235,7 @@ def test_read_rar3(): for fn in rf.namelist(): rf.read(fn) -@with_setup(install_alt_tool, uninstall_alt_tool) +#@with_setup(install_alt_tool, uninstall_alt_tool) def test_alt_tool(): #test_read_rar3() pass diff --git a/test/test_crypto.py b/test/test_crypto.py dissimilarity index 60% index 909f0ee..384eb9e 100644 --- a/test/test_crypto.py +++ b/test/test_crypto.py @@ -1,44 +1,45 @@ -"""Crypto tests. -""" - -from __future__ import division, print_function - -from binascii import unhexlify - -from nose.tools import * - -import rarfile - -try: - from cryptography.hazmat.primitives.ciphers import algorithms, modes, Cipher - from cryptography.hazmat.backends import default_backend - def aes_encrypt(key, iv, data): - ciph = Cipher(algorithms.AES(key), modes.CBC(iv), default_backend()) - enc = ciph.encryptor() - return enc.update(data) -except ImportError: - pass - -if rarfile._have_crypto: - def test_aes128_cbc(): - data = b'0123456789abcdef' * 2 - key = b'\x02' * 16 - iv = b'\x80' * 16 - - #encdata = aes_encrypt(key, iv, data) - encdata = unhexlify('4b0d438b4a1b972bd4ab81cd64674dcce4b0158090fbe616f455354284d53502') - - ctx = rarfile.AES_CBC_Decrypt(key, iv) - eq_(ctx.decrypt(encdata), data) - - def test_aes256_cbc(): - data = b'0123456789abcdef' * 2 - key = b'\x52' * 32 - iv = b'\x70' * 16 - - #encdata = aes_encrypt(key, iv, data) - encdata = unhexlify('24988f387592e4d95b6eaab013137a221f81b25aa7ecde0ef4f4d7a95f92c250') - - ctx = rarfile.AES_CBC_Decrypt(key, iv) - eq_(ctx.decrypt(encdata), data) - +"""Crypto tests. +""" + +from __future__ import division, print_function + +from binascii import unhexlify + +import pytest + +import rarfile + +try: + from cryptography.hazmat.primitives.ciphers import algorithms, modes, Cipher + from cryptography.hazmat.backends import default_backend + def aes_encrypt(key, iv, data): + ciph = Cipher(algorithms.AES(key), modes.CBC(iv), default_backend()) + enc = ciph.encryptor() + return enc.update(data) +except ImportError: + pass + +@pytest.mark.skipif(not rarfile._have_crypto, reason="No crypto") +def test_aes128_cbc(): + data = b'0123456789abcdef' * 2 + key = b'\x02' * 16 + iv = b'\x80' * 16 + + #encdata = aes_encrypt(key, iv, data) + encdata = unhexlify('4b0d438b4a1b972bd4ab81cd64674dcce4b0158090fbe616f455354284d53502') + + ctx = rarfile.AES_CBC_Decrypt(key, iv) + assert ctx.decrypt(encdata) == data + +@pytest.mark.skipif(not rarfile._have_crypto, reason="No crypto") +def test_aes256_cbc(): + data = b'0123456789abcdef' * 2 + key = b'\x52' * 32 + iv = b'\x70' * 16 + + #encdata = aes_encrypt(key, iv, data) + encdata = unhexlify('24988f387592e4d95b6eaab013137a221f81b25aa7ecde0ef4f4d7a95f92c250') + + ctx = rarfile.AES_CBC_Decrypt(key, iv) + assert ctx.decrypt(encdata) == data + diff --git a/test/test_format.py b/test/test_format.py index db88b63..4523c20 100644 --- a/test/test_format.py +++ b/test/test_format.py @@ -1,13 +1,8 @@ """Format details. """ -import sys -import io -import os - from datetime import datetime -from nose.tools import * - +import pytest import rarfile def render_date(dt): @@ -63,41 +58,37 @@ def diffs(a, b): return '; '.join(problems) def cmp_struct(a, b): - eq_(a, b, diffs(a, b)) + assert a == b, diffs(a, b) # # test start # +@pytest.mark.skipif(not rarfile._have_crypto, reason="No crypto") def test_rar3_header_encryption(): r = rarfile.RarFile('test/files/rar3-comment-hpsw.rar', 'r') - eq_(r.needs_password(), True) - eq_(r.comment, None) - eq_(r.namelist(), []) - - try: - r.setpassword('password') - assert_true(r.needs_password()) - eq_(r.namelist(), [u'file1.txt', u'file2.txt']) - assert_not_equal(r.comment, None) - eq_(r.comment, 'RARcomment\n') - except rarfile.NoCrypto: - pass + assert r.needs_password() is True + assert r.comment is None + assert r.namelist() == [] + + r.setpassword('password') + assert r.needs_password() is True + assert r.namelist() == [u'file1.txt', u'file2.txt'] + assert r.comment is not None + assert r.comment == 'RARcomment\n' +@pytest.mark.skipif(not rarfile._have_crypto, reason="No crypto") def test_rar5_header_encryption(): r = rarfile.RarFile('test/files/rar5-hpsw.rar') - eq_(r.needs_password(), True) - eq_(r.comment, None) - eq_(r.namelist(), []) - - try: - r.setpassword('password') - assert_true(r.needs_password()) - eq_(r.namelist(), [u'stest1.txt', u'stest2.txt']) - assert_not_equal(r.comment, None) - eq_(r.comment, 'RAR5 archive - hdr-password\n') - except rarfile.NoCrypto: - pass + assert r.needs_password() is True + assert r.comment is None + assert r.namelist() == [] + + r.setpassword('password') + assert r.needs_password() is True + assert r.namelist() == [u'stest1.txt', u'stest2.txt'] + assert r.comment is not None + assert r.comment == 'RAR5 archive - hdr-password\n' r.close() def get_vol_info(extver=20, tz='', hr='11'): @@ -125,36 +116,36 @@ def get_vol_info(extver=20, tz='', hr='11'): def test_rar3_vols(): r = rarfile.RarFile('test/files/rar3-vols.part1.rar') - eq_(r.needs_password(), False) - eq_(r.comment, None) - eq_(r.strerror(), None) + assert r.needs_password() is False + assert r.comment is None + assert r.strerror() is None cmp_struct(dumparc(r), get_vol_info()) - eq_(r.volumelist(), [ + assert r.volumelist() == [ 'test/files/rar3-vols.part1.rar', 'test/files/rar3-vols.part2.rar', - 'test/files/rar3-vols.part3.rar']) + 'test/files/rar3-vols.part3.rar'] def test_rar3_oldvols(): r = rarfile.RarFile('test/files/rar3-old.rar') - eq_(r.needs_password(), False) - eq_(r.comment, None) - eq_(r.strerror(), None) + assert r.needs_password() is False + assert r.comment is None + assert r.strerror() is None cmp_struct(dumparc(r), get_vol_info()) - eq_(r.volumelist(), [ + assert r.volumelist() == [ 'test/files/rar3-old.rar', 'test/files/rar3-old.r00', - 'test/files/rar3-old.r01']) + 'test/files/rar3-old.r01'] def test_rar5_vols(): r = rarfile.RarFile('test/files/rar5-vols.part1.rar') - eq_(r.needs_password(), False) - eq_(r.comment, None) - eq_(r.strerror(), None) + assert r.needs_password() is False + assert r.comment is None + assert r.strerror() is None cmp_struct(dumparc(r), get_vol_info(50, '+00:00', '08')) - eq_(r.volumelist(), [ + assert r.volumelist() == [ 'test/files/rar5-vols.part1.rar', 'test/files/rar5-vols.part2.rar', - 'test/files/rar5-vols.part3.rar']) + 'test/files/rar5-vols.part3.rar'] def expect_ctime(mtime, ctime): return [mkitem( @@ -207,17 +198,17 @@ def test_rar5_times(): )]) def test_oldvols(): - eq_(rarfile._next_oldvol('qq00.part0.rar'), 'qq00.part0.r00') - eq_(rarfile._next_oldvol('qq00.part0.r00'), 'qq00.part0.r01') - eq_(rarfile._next_oldvol('qq00.part0.r29'), 'qq00.part0.r30') - eq_(rarfile._next_oldvol('qq00.part0.r99'), 'qq00.part0.s00') + assert rarfile._next_oldvol('qq00.part0.rar') == 'qq00.part0.r00' + assert rarfile._next_oldvol('qq00.part0.r00') == 'qq00.part0.r01' + assert rarfile._next_oldvol('qq00.part0.r29') == 'qq00.part0.r30' + assert rarfile._next_oldvol('qq00.part0.r99') == 'qq00.part0.s00' def test_newvols(): - eq_(rarfile._next_newvol('qq00.part0.rar'), 'qq00.part1.rar') - eq_(rarfile._next_newvol('qq00.part09.rar'), 'qq00.part10.rar') - eq_(rarfile._next_newvol('qq00.part99.rar'), 'qq00.paru00.rar') + assert rarfile._next_newvol('qq00.part0.rar') == 'qq00.part1.rar' + assert rarfile._next_newvol('qq00.part09.rar') == 'qq00.part10.rar' + assert rarfile._next_newvol('qq00.part99.rar') == 'qq00.paru00.rar' -@raises(rarfile.BadRarName) def test_newvols_err(): - rarfile._next_newvol('xx.rar') + with pytest.raises(rarfile.BadRarName): + rarfile._next_newvol('xx.rar') diff --git a/test/test_hashing.py b/test/test_hashing.py index 614e209..99e1494 100644 --- a/test/test_hashing.py +++ b/test/test_hashing.py @@ -4,32 +4,28 @@ from __future__ import division, print_function import hashlib - from binascii import unhexlify -from nose.tools import * - import rarfile - from rarfile import Blake2SP, CRC32Context, NoHashContext, tohex, Rar3Sha1 def test_nohash(): - eq_(NoHashContext('').hexdigest(), None) - eq_(NoHashContext('asd').hexdigest(), None) + assert NoHashContext('').hexdigest() is None + assert NoHashContext('asd').hexdigest() is None md = NoHashContext() md.update('asd') - eq_(md.digest(), None) + assert md.digest() is None def test_crc32(): - eq_(CRC32Context(b'').hexdigest(), '00000000') - eq_(CRC32Context(b'Hello').hexdigest(), 'f7d18982') - eq_(CRC32Context(b'Bye').hexdigest(), '4f7ad7d4') + assert CRC32Context(b'').hexdigest() == '00000000' + assert CRC32Context(b'Hello').hexdigest() == 'f7d18982' + assert CRC32Context(b'Bye').hexdigest() == '4f7ad7d4' md = CRC32Context() md.update(b'He') md.update(b'll') md.update(b'o') - eq_(md.hexdigest(), 'f7d18982') + assert md.hexdigest() == 'f7d18982' def xblake2sp(xdata): data = unhexlify(xdata) @@ -50,28 +46,28 @@ def xblake2sp_slow(xdata): if rarfile._have_blake2: def test_blake2sp(): - eq_(Blake2SP(b'').hexdigest(), 'dd0e891776933f43c7d032b08a917e25741f8aa9a12c12e1cac8801500f2ca4f') - eq_(Blake2SP(b'Hello').hexdigest(), '0d6bae0db99f99183d060f7994bb94b45c6490b2a0a628b8b1346ebea8ec1d66') + assert Blake2SP(b'').hexdigest() == 'dd0e891776933f43c7d032b08a917e25741f8aa9a12c12e1cac8801500f2ca4f' + assert Blake2SP(b'Hello').hexdigest() == '0d6bae0db99f99183d060f7994bb94b45c6490b2a0a628b8b1346ebea8ec1d66' - eq_(xblake2sp(''), 'dd0e891776933f43c7d032b08a917e25741f8aa9a12c12e1cac8801500f2ca4f') - eq_(xblake2sp('00'), 'a6b9eecc25227ad788c99d3f236debc8da408849e9a5178978727a81457f7239') + assert xblake2sp('') == 'dd0e891776933f43c7d032b08a917e25741f8aa9a12c12e1cac8801500f2ca4f' + assert xblake2sp('00') == 'a6b9eecc25227ad788c99d3f236debc8da408849e9a5178978727a81457f7239' long1 = '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031' - eq_(xblake2sp(long1), '270affa6426f1a515c9b76dfc27d181fc2fd57d082a3ba2c1eef071533a6dfb7') + assert xblake2sp(long1) == '270affa6426f1a515c9b76dfc27d181fc2fd57d082a3ba2c1eef071533a6dfb7' long2 = long1 * 20 - eq_(xblake2sp(long2), '24a78d92592d0761a3681f32935225ca55ffb8eb16b55ab9481c89c59a985ff3') - eq_(xblake2sp_slow(long2), '24a78d92592d0761a3681f32935225ca55ffb8eb16b55ab9481c89c59a985ff3') + assert xblake2sp(long2) == '24a78d92592d0761a3681f32935225ca55ffb8eb16b55ab9481c89c59a985ff3' + assert xblake2sp_slow(long2) == '24a78d92592d0761a3681f32935225ca55ffb8eb16b55ab9481c89c59a985ff3' def test_hmac_sha256(): - eq_(tohex(rarfile.hmac_sha256(b'key', b'data')), '5031fe3d989c6d1537a013fa6e739da23463fdaec3b70137d828e36ace221bd0') + assert tohex(rarfile.hmac_sha256(b'key', b'data')) == '5031fe3d989c6d1537a013fa6e739da23463fdaec3b70137d828e36ace221bd0' def test_rar3_sha1(): for n in range(0, 200): data = bytearray([i for i in range(n)]) h1 = hashlib.sha1(data).hexdigest() h2 = Rar3Sha1(data).hexdigest() - eq_(h1, h2) + assert h1 == h2 data = bytearray([(i & 255) for i in range(2000)]) x1 = hashlib.sha1() @@ -84,25 +80,25 @@ def test_rar3_sha1(): pos2 = len(data) x1.update(data[pos:pos2]) x2.update(data[pos:pos2]) - eq_(x1.hexdigest(), x2.hexdigest()) + assert x1.hexdigest() == x2.hexdigest() pos = pos2 def test_rar3_s2k(): exp = ('a160cb31cb262e9231c0b6fc984fbb0d', 'aa54a659fb0c359b30f353a6343fb11d') key, iv = rarfile.rar3_s2k(b'password', unhexlify('00FF00')) - eq_((tohex(key), tohex(iv)), exp) + assert (tohex(key), tohex(iv)) == exp key, iv = rarfile.rar3_s2k(u'password', unhexlify('00FF00')) - eq_((tohex(key), tohex(iv)), exp) + assert (tohex(key), tohex(iv)) == exp exp = ('ffff33ffaf31987c899ccc2f965a8927', 'bdff6873721b247afa4f978448a5aeef') key, iv = rarfile.rar3_s2k(u'p'*28, unhexlify('1122334455667788')) - eq_((tohex(key), tohex(iv)), exp) + assert (tohex(key), tohex(iv)) == exp exp = ('306cafde28f1ea78c9427c3ec642c0db', '173ecdf574c0bfe9e7c23bdfd96fa435') key, iv = rarfile.rar3_s2k(u'p'*29, unhexlify('1122334455667788')) - eq_((tohex(key), tohex(iv)), exp) + assert (tohex(key), tohex(iv)) == exp if rarfile._have_crypto: def test_pbkdf2_hmac_sha256(): - eq_(tohex(rarfile.pbkdf2_sha256(b'password', b'salt', 100)), - '07e6997180cf7f12904f04100d405d34888fdf62af6d506a0ecc23b196fe99d8') + assert tohex(rarfile.pbkdf2_sha256(b'password', b'salt', 100)) == \ + '07e6997180cf7f12904f04100d405d34888fdf62af6d506a0ecc23b196fe99d8' diff --git a/test/test_korrupt.py b/test/test_korrupt.py index 422b3b2..d3a661d 100644 --- a/test/test_korrupt.py +++ b/test/test_korrupt.py @@ -1,9 +1,9 @@ """test corrupt file parsing. """ -import rarfile import glob import io +import rarfile def try_read(tmpfn): try: diff --git a/test/test_reading.py b/test/test_reading.py index 87fb175..0354fb8 100644 --- a/test/test_reading.py +++ b/test/test_reading.py @@ -2,13 +2,10 @@ """ import io - from glob import glob - +import pytest import rarfile -from nose.tools import * - _done_reading = set() def run_reading_normal(fn, comment): @@ -18,8 +15,8 @@ def run_reading_normal(fn, comment): return if rf.needs_password(): rf.setpassword('password') - eq_(rf.strerror(), None) - eq_(rf.comment, comment) + assert rf.strerror() is None + assert rf.comment == comment for ifn in rf.namelist(): # full read @@ -35,7 +32,7 @@ def run_reading_normal(fn, comment): break total += len(buf) f.close() - eq_(total, item.file_size) + assert total == item.file_size # read from stream with readinto bbuf = bytearray(1024) @@ -84,12 +81,13 @@ def test_reading_rar2_psw(): def test_reading_rar3_psw(): run_reading('test/files/rar3-comment-psw.rar', u'RARcomment\n') -if rarfile._have_crypto: - def test_reading_rar3_hpsw(): - run_reading('test/files/rar3-comment-hpsw.rar', u'RARcomment\n') -else: - @raises(rarfile.NoCrypto) - def test_reading_rar3_hpsw_nocrypto(): +@pytest.mark.skipif(not rarfile._have_crypto, reason="No crypto") +def test_reading_rar3_hpsw(): + run_reading('test/files/rar3-comment-hpsw.rar', u'RARcomment\n') + +@pytest.mark.skipif(rarfile._have_crypto, reason="Has crypto") +def test_reading_rar3_hpsw_nocrypto(): + with pytest.raises(rarfile.NoCrypto): run_reading('test/files/rar3-comment-hpsw.rar', u'RARcomment\n') def test_reading_rar3_vols(): @@ -126,12 +124,13 @@ def test_reading_rar5_vols(): run_reading('test/files/rar5-vols.part2.rar') run_reading('test/files/rar5-vols.part3.rar') -if rarfile._have_crypto: - def test_reading_rar5_hpsw(): - run_reading('test/files/rar5-hpsw.rar', u'RAR5 archive - hdr-password\n') -else: - @raises(rarfile.NoCrypto) - def test_reading_rar5_hpsw(): +@pytest.mark.skipif(not rarfile._have_crypto, reason="No crypto") +def test_reading_rar5_hpsw(): + run_reading('test/files/rar5-hpsw.rar', u'RAR5 archive - hdr-password\n') + +@pytest.mark.skipif(rarfile._have_crypto, reason="Has crypto") +def test_reading_rar5_hpsw_nocrypto(): + with pytest.raises(rarfile.NoCrypto): run_reading('test/files/rar5-hpsw.rar', u'RAR5 archive - hdr-password\n') def test_reading_rar5_psw_blake(): @@ -147,5 +146,5 @@ def test_reading_missed(): fn = fn.replace('\\', '/') if fn not in _done_reading: missed.append(fn) - eq_(missed, problems) + assert missed == problems diff --git a/test/test_seek.py b/test/test_seek.py index 7028704..0b93685 100644 --- a/test/test_seek.py +++ b/test/test_seek.py @@ -4,8 +4,6 @@ import io import rarfile -from nose.tools import * - ARC = 'test/files/seektest.rar' def do_seek(f, pos, lim): @@ -23,7 +21,7 @@ def do_seek(f, pos, lim): got = f.tell() - eq_(got, exp) + assert got == exp ln = f.read(4) if got == fsize and ln: raise Exception('unexpected read') @@ -31,7 +29,7 @@ def do_seek(f, pos, lim): raise Exception('unexpected read failure') if ln: spos = int(ln) - eq_(spos*4, got) + assert spos*4 == got def run_seek(rf, fn): inf = rf.getinfo(fn) diff --git a/tox.ini b/tox.ini dissimilarity index 79% index 8c674cb..32a8852 100644 --- a/tox.ini +++ b/tox.ini @@ -1,41 +1,50 @@ - -[tox] -envlist = lint,docs,py27,py34,py35,py36 - -[testenv] -deps = nose - py34: pycrypto - py35: pyblake2 - py35: cryptography - py36: cryptography -commands = - nosetests [] - sh ./test/run_dump.sh {envpython} {envname} -whitelist_externals = sh - -[testenv:py27] -usedevelop = True -deps = nose - coverage - pyblake2 - pycrypto -commands = - nosetests --with-coverage --cover-erase --cover-package=rarfile --cover-html --cover-html-dir=tmp/cover-py27 [] - sh ./test/run_dump.sh {envpython} {envname} - -[testenv:lint] -basepython = python3 -deps = prospector[with_everything] - pyblake2 - pycrypto -commands = prospector rarfile.py dumprar.py - -[testenv:docs] -basepython = python3 -deps = sphinx - docutils -changedir = doc -commands = - sphinx-build -q -W -b html -d {envtmpdir}/doctrees . ../tmp/dochtml - rst2html.py ../README.rst ../tmp/dochtml/README.html - + +[tox] +envlist = lint,docs,py2,py37-pycrypto,py36-cryptography,py38 + +[package] +name = rarfile +test_deps = + pytest==5.1.2 + pytest-cov==2.7.1 +doc_deps = + sphinx==2.2.0 + docutils==0.15.2 +lint_deps = + pylint==2.3.1 + +[testenv] +deps = {[package]test_deps} + pycrypto: pycrypto==2.6.1 + pycrypto: pyblake2==1.1.2 + cryptography: cryptography==2.6.1 + +commands = + pytest -vv --cov=rarfile --cov-report=term {toxinidir}/test --cov-report=html:{toxinidir}/cover/{envname} {posargs} + sh ./test/run_dump.sh {envpython} {envname} +whitelist_externals = sh + +[testenv:py2] +basepython = python2.7 +deps = + pytest==4.6.5 + pytest-cov==2.7.1 + pycrypto==2.6.1 + pyblake2==1.1.2 + +[testenv:lint] +basepython = python3 +deps = {[package]lint_deps} + {[package]test_deps} +commands = + pylint rarfile.py dumprar.py + pylint test + +[testenv:docs] +basepython = python3 +deps = {[package]doc_deps} +changedir = doc +commands = + sphinx-build -q -W -b html -d {envtmpdir}/doctrees . ../tmp/dochtml + rst2html.py ../README.rst ../tmp/dochtml/README.html + -- 2.11.4.GIT