From ab23c593565a50c6dc54b7630a141b68a743d37f Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Sun, 30 Oct 2016 22:12:39 -0200 Subject: [PATCH 1/8] [REF] Move install_requires to requirements.txt --- requirements.txt | 3 +++ setup.py | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..54fbbcec --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +-e git://github.com/odoo-brazil/pyxmlsec.git@master#egg=pyxmlsec +-e git://github.com/odoo-brazil/geraldo.git@master#egg=geraldo + diff --git a/setup.py b/setup.py index 401d8f74..54069546 100644 --- a/setup.py +++ b/setup.py @@ -46,8 +46,7 @@ description = 'PySPED is a library to implement all requirements of the public system of bookkeeping digital', long_description = open('README.rst').read(), install_requires=[ - 'Geraldo >= 0.4.16', - 'PyXMLSec >= 0.3.0' + # List of dependencies is moved to pip-requirements.txt ], tests_require=[ 'pyflakes>=0.6.1', From 281dc5ef9850f55ea95d5eaf2aafd144fc116a8e Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Sun, 30 Oct 2016 22:13:00 -0200 Subject: [PATCH 2/8] [NEW] Add travis test --- .travis.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..6c5db6af --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: python +dist: trusty + +python: + - "2.7" + +sudo: required + +cache: + pip: true + +addons: + apt: + packages: + - libxml2-dev + - libxmlsec1-dev + +before_install: + - sudo locale-gen en_US en_US.UTF-8 pt_BR.UTF-8 + - sudo dpkg-reconfigure locales + +install: + - virtualenv . + - bin/pip install -r requirements.txt + +script: + - bin/python setup.py test + + From 5781fd72c7e73a61600395f23cb679adbbe7ecb0 Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Sun, 30 Oct 2016 22:17:56 -0200 Subject: [PATCH 3/8] [NEW] Add test dependencies --- .travis.yml | 1 + setup.py | 4 ++-- test-requirements.txt | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 test-requirements.txt diff --git a/.travis.yml b/.travis.yml index 6c5db6af..f88658f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ before_install: install: - virtualenv . - bin/pip install -r requirements.txt + - bin/pip install -r test-requirements.txt script: - bin/python setup.py test diff --git a/setup.py b/setup.py index 54069546..338a9c83 100644 --- a/setup.py +++ b/setup.py @@ -46,9 +46,9 @@ description = 'PySPED is a library to implement all requirements of the public system of bookkeeping digital', long_description = open('README.rst').read(), install_requires=[ - # List of dependencies is moved to pip-requirements.txt + # List of dependencies is moved to requirements.txt ], tests_require=[ - 'pyflakes>=0.6.1', + # List of dependencies is moved to test-requirements.txt ], ) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..d97bf366 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +pyflakes>=0.6.1 \ No newline at end of file From d743a21a92ab358f471bca5ee30ef52795b26227 Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Mon, 31 Oct 2016 01:01:12 -0200 Subject: [PATCH 4/8] [REM] pyflake tests --- setup.py | 1 - test-requirements.txt | 1 - tests/__init__.py | 0 tests/compat.py | 16 ------ tests/test_pyflakes.py | 118 ----------------------------------------- tests/testutils.py | 83 ----------------------------- 6 files changed, 219 deletions(-) delete mode 100644 tests/__init__.py delete mode 100644 tests/compat.py delete mode 100644 tests/test_pyflakes.py delete mode 100644 tests/testutils.py diff --git a/setup.py b/setup.py index 338a9c83..eb8adaa5 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,6 @@ version = "0.1.2", author = "Aristides Caldeira", author_email = 'aristides.caldeira@tauga.com.br', - test_suite='tests', keywords = ['nfe', 'nfse', 'cte', 'sped', 'edf', 'ecd'], classifiers=[ 'Development Status :: 4 - Beta', diff --git a/test-requirements.txt b/test-requirements.txt index d97bf366..e69de29b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +0,0 @@ -pyflakes>=0.6.1 \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/compat.py b/tests/compat.py deleted file mode 100644 index 082efed9..00000000 --- a/tests/compat.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -import unittest - - -def _skipIf(check, message=''): - def _deco(meth): - if check: - return lambda *a, **kw: None - else: - return meth - return _deco - -if hasattr(unittest, 'skipIf'): - skipIf = unittest.skipIf -else: - skipIf = _skipIf diff --git a/tests/test_pyflakes.py b/tests/test_pyflakes.py deleted file mode 100644 index 9fe80d2f..00000000 --- a/tests/test_pyflakes.py +++ /dev/null @@ -1,118 +0,0 @@ -# -*- coding: utf-8 -*- -# vi:si:et:sw=4:sts=4:ts=4 - -## -## Copyright (C) 2011-2012 Async Open Source -## All rights reserved -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., or visit: http://www.gnu.org/. -## -## Author(s): Stoq Team -## -"""Test pyflakes on stoq, stoqlib and plugins directories - -Useful to early find syntax errors and other common problems. - -""" -import _ast -import sys -import unittest - -from testutils import SourceTest -from compat import skipIf - - -try: - from pyflakes import checker -except ImportError as err: - if sys.version_info >= (3,): - pass # Pyflakes doesn't support Python3 - else: - raise(err) - - -@skipIf(sys.version_info >= (3,), - "Pyflakes unavailable on this version") -class TestPyflakes(SourceTest, unittest.TestCase): - def setUp(self): - pass - - # stolen from pyflakes - def _check(self, codeString, filename, warnings): - try: - tree = compile(codeString, filename, "exec", _ast.PyCF_ONLY_AST) - except (SyntaxError, IndentationError) as value: - msg = value.args[0] - - (lineno, offset, text) = value.lineno, value.offset, value.text - - # If there's an encoding problem with the file, the text is None. - if text is None: - # Avoid using msg, since for the only known case, it contains a - # bogus message that claims the encoding the file declared was - # unknown. - print >> sys.stderr, "%s: problem decoding source" % ( - filename, - ) - else: - line = text.splitlines()[-1] - - if offset is not None: - offset = offset - (len(text) - len(line)) - - print >> sys.stderr, '%s:%d: %s' % (filename, lineno, msg) - print >> sys.stderr, line - - if offset is not None: - print >> sys.stderr, " " * offset, "^" - - return 1 - except UnicodeError as msg: - print >> sys.stderr, 'encoding error at %r: %s' % (filename, msg) - return 1 - else: - # Okay, it's syntactically valid. - # Now parse it into an ast and check it. - w = checker.Checker(tree, filename) - warnings.extend(w.messages) - return len(warnings) - - def check_filename(self, root, filename): - warnings = [] - msgs = [] - result = 0 - try: - fd = open(filename, 'U') - try: - result = self._check(fd.read(), filename, warnings) - finally: - fd.close() - except IOError as msg: - print >> sys.stderr, "%s: %s" % (filename, msg.args[1]) - result = 1 - - warnings.sort(key=lambda w: w.lineno) - for warning in warnings: - msg = str(warning).replace(root, '') - print msg - msgs.append(msg) - if result: - raise AssertionError( - "%d warnings:\n%s\n" % (len(msgs), '\n'.join(msgs), )) - -suite = unittest.TestLoader().loadTestsFromTestCase(TestPyflakes) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/testutils.py b/tests/testutils.py deleted file mode 100644 index 18407138..00000000 --- a/tests/testutils.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- -import fnmatch -import os - -import pysped - - -def list_recursively(directory, pattern): - """Returns files recursively from directory matching pattern - :param directory: directory to list - :param pattern: glob mattern to match - """ - matches = [] - for root, dirnames, filenames in os.walk(directory): - for filename in fnmatch.filter(filenames, pattern): - # skip backup files - if (filename.startswith('.#') or - filename.endswith('~')): - continue - matches.append(os.path.join(root, filename)) - return matches - - -def get_sources(root): - for dirpath in ['pysped', 'tests']: - path = os.path.join(root, dirpath) - for fname in list_recursively(path, '*.py'): - if fname.endswith('__init__.py'): - continue - yield fname - - #yield os.path.join(root, 'setup.py') - - -class ClassInittableMetaType(type): - # pylint fails to understand this is a metaclass - def __init__(self, name, bases, namespace): - type.__init__(self, name, bases, namespace) - self.__class_init__(namespace) - - -class SourceTest(object): - __metaclass__ = ClassInittableMetaType - - @classmethod - def __class_init__(cls, namespace): - root = os.path.dirname(os.path.dirname(pysped.__file__)) - cls.root = root - for filename in get_sources(root): - testname = filename[len(root):] - if not cls.filename_filter(testname): - continue - testname = testname[:-3].replace('/', '_') - name = 'test_%s' % (testname, ) - func = lambda self, r=root, f=filename: self.check_filename(r, f) - func.__name__ = name - setattr(cls, name, func) - - def check_filename(self, root, filename): - pass - - @classmethod - def filename_filter(cls, filename): - if cls.__name__ == 'SourceTest': - return False - else: - return True - - -def indent(elem, level=0): - i = "\n" + level * " " - if len(elem): - if not elem.text or not elem.text.strip(): - elem.text = i + " " - if not elem.tail or not elem.tail.strip(): - elem.tail = i - for elem in elem: - indent(elem, level + 1) - if not elem.tail or not elem.tail.strip(): - elem.tail = i - else: - if level and (not elem.tail or not elem.tail.strip()): - elem.tail = i From c11c264a6218dbf1b94bd4d864efd70f1f6aa244 Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Mon, 31 Oct 2016 01:07:37 -0200 Subject: [PATCH 5/8] [NEW] Enable some tests --- .travis.yml | 4 ++-- setup.py | 4 ++++ test-requirements.txt | 3 +++ test/__init__.py | 1 + test/empty_test.py | 11 +++++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/__init__.py create mode 100644 test/empty_test.py diff --git a/.travis.yml b/.travis.yml index f88658f3..5fa581db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,6 @@ install: - bin/pip install -r test-requirements.txt script: + - bin/python setup.py flake8 + - bin/python setup.py lint - bin/python setup.py test - - diff --git a/setup.py b/setup.py index eb8adaa5..417c914b 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ version = "0.1.2", author = "Aristides Caldeira", author_email = 'aristides.caldeira@tauga.com.br', + test_suite='test', keywords = ['nfe', 'nfse', 'cte', 'sped', 'edf', 'ecd'], classifiers=[ 'Development Status :: 4 - Beta', @@ -47,6 +48,9 @@ install_requires=[ # List of dependencies is moved to requirements.txt ], + setup_requires=[ + "flake8" + ], tests_require=[ # List of dependencies is moved to test-requirements.txt ], diff --git a/test-requirements.txt b/test-requirements.txt index e69de29b..7dcf7265 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -0,0 +1,3 @@ +flake8 +setuptools-lint +coveralls \ No newline at end of file diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 00000000..40a96afc --- /dev/null +++ b/test/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/test/empty_test.py b/test/empty_test.py new file mode 100644 index 00000000..d1775cb8 --- /dev/null +++ b/test/empty_test.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +from unittest import TestCase + +class TestEmpty(TestCase): + + def setUp(self): + pass + + def test_empty_01(self): + pass \ No newline at end of file From 8bdf1b1c7ae7daa24efe77f7bea5c5ab1da8afe4 Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Mon, 31 Oct 2016 01:09:29 -0200 Subject: [PATCH 6/8] [ADD] entries to gitignore --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index b7422ed2..fc8b0245 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,12 @@ build/ dist/ *egg*/ docs/_build +.coverage +.idea/ +bin/ +include/ +lib/ +local/ +pip-selfcheck.json +src/ +venv/ From b98f3c02bb34fc8e379d6b4b9c65c26bc47e81ea Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Mon, 31 Oct 2016 01:25:29 -0200 Subject: [PATCH 7/8] [NEW] Split testes --- .travis.yml | 9 ++++++--- travis_run_script.sh | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 travis_run_script.sh diff --git a/.travis.yml b/.travis.yml index 5fa581db..cb1beb7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,11 @@ addons: - libxml2-dev - libxmlsec1-dev +env: + - LINT="1" FLAKE="0" TEST="0" + - LINT="0" FLAKE="1" TEST="0" + - LINT="0" FLAKE="0" TEST="1" + before_install: - sudo locale-gen en_US en_US.UTF-8 pt_BR.UTF-8 - sudo dpkg-reconfigure locales @@ -25,6 +30,4 @@ install: - bin/pip install -r test-requirements.txt script: - - bin/python setup.py flake8 - - bin/python setup.py lint - - bin/python setup.py test + - sh travis_run_script.sh diff --git a/travis_run_script.sh b/travis_run_script.sh new file mode 100644 index 00000000..99e8b091 --- /dev/null +++ b/travis_run_script.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -e + +if [ "${TEST}" != "0" ]; then + bin/python setup.py test + exit 0 +fi + +if [ "${FLAKE}" != "0" ]; then + bin/python setup.py flake8 + exit 0 +fi + +if [ "${LINT}" != "0" ]; then + bin/python setup.py lint + exit 0 +fi + +set +e \ No newline at end of file From ab48ff0684598495cb3244effd5078dd0ac05463 Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Mon, 31 Oct 2016 08:41:58 -0200 Subject: [PATCH 8/8] Add libxml2 to requirements --- .travis.yml | 5 +++++ requirements.txt | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cb1beb7e..b004d9ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,11 @@ addons: packages: - libxml2-dev - libxmlsec1-dev + - python-dev + - libffi-dev + - libxslt1-dev + - libssl-dev + - libxmlsec1-dev env: - LINT="1" FLAKE="0" TEST="0" diff --git a/requirements.txt b/requirements.txt index 54fbbcec..5035ef3c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ -e git://github.com/odoo-brazil/pyxmlsec.git@master#egg=pyxmlsec -e git://github.com/odoo-brazil/geraldo.git@master#egg=geraldo - +-e git://github.com/odoo-brazil/libxml2.git@master#egg=libxml2 +lxml +pytz