Skip to content

Commit

Permalink
[REF] tests
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Felipe Miléo <[email protected]>
  • Loading branch information
mileo committed Jul 16, 2024
1 parent 4f68793 commit 3c848ee
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 166 deletions.
46 changes: 0 additions & 46 deletions .appveyor.yml

This file was deleted.

85 changes: 53 additions & 32 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

name: build
on: [push, pull_request]
jobs:
build:

runs-on: ubuntu-latest
test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ["3.5", "3.8", "3.10"]
include:
- name: 'check'
python: '3.9'
toxpython: 'python3.9'
tox_env: 'check'
os: 'ubuntu-latest'
- name: 'py37 (ubuntu)'
python: '3.7'
toxpython: 'python3.7'
python_arch: 'x64'
tox_env: 'py37'
os: 'ubuntu-latest'
- name: 'py38 (ubuntu)'
python: '3.8'
toxpython: 'python3.8'
python_arch: 'x64'
tox_env: 'py38'
os: 'ubuntu-latest'
- name: 'py39 (ubuntu)'
python: '3.9'
toxpython: 'python3.9'
python_arch: 'x64'
tox_env: 'py39'
os: 'ubuntu-latest'
- name: 'py310 (ubuntu)'
python: '3.10'
toxpython: 'python3.10'
python_arch: 'x64'
tox_env: 'py310'
os: 'ubuntu-latest'

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.python_arch }}
- name: install dependencies
run: |
pytest
python -mpip install --progress-bar=off -r ci/requirements.txt
virtualenv --version
pip --version
tox --version
pip list --format=freeze
- name: test
env:
TOXPYTHON: '${{ matrix.toxpython }}'
run: >
tox -e ${{ matrix.tox_env }} -v
52 changes: 0 additions & 52 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions ci/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
virtualenv>=16.6.0
pip>=19.1.1
setuptools>=18.0.1
tox
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def read(*names, **kwargs):
'lxml',
'py3o.template',
'sh',
'pytz',
'python-dateutil',
# eg: 'aspectlib==1.1.1', 'six>=1.7',
],
Expand Down
12 changes: 5 additions & 7 deletions src/erpbrasil/edoc/pdf/danfe_formata.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# -*- coding: utf-8 -*-
import base64
import locale
import pytz

from datetime import datetime
from dateutil.parser import parse

from genshi import Markup
from reportlab.graphics.barcode import createBarcodeDrawing

import pytz
from dateutil.parser import parse
from erpbrasil.base.fiscal import cnpj_cpf
from erpbrasil.base.misc import format_zipcode
from genshi import Markup
from reportlab.graphics.barcode import createBarcodeDrawing


def formata_decimal(numero, digitos):
Expand Down Expand Up @@ -145,7 +143,7 @@ def formata_dhRecbto(dhRecbto):
# FIXME em algum ponto o valor do campo esta sendo formatado para string
# deveria ter um tratamento caso o valor seja None deveria retornar a string
# vazia '' ao invés de retornar 'None'
if dhRecbto is 'None':
if dhRecbto == 'None':
return ''
else:
dhRecbto = str(dhRecbto)
Expand Down
2 changes: 1 addition & 1 deletion src/erpbrasil/edoc/pdf/nfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __getattribute__(*args):
result = objectify.ObjectifiedElement.__getattribute__(*args)

# Caso existe um metodo de formatação para o atributo no danfe_formatado
if type(result) == NFeElement:
if type(result) is NFeElement:
search = re.search('{.*}(.*)', result.tag)
if not search:
return result
Expand Down
14 changes: 8 additions & 6 deletions tests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
OUTPUT = 'output'
TIPO = 'danfe'

for (dirpath, dirnames, filenames) in walk(PATH):
for file in filenames:
arquivo = path.join(PATH, file)
output = path.join(OUTPUT, file)

print('XML: ' + file)
print(base.ImprimirXml.imprimir(caminho_xml=arquivo, output_dir=output))
def test_pdf_gen():
for (dirpath, dirnames, filenames) in walk(PATH):
for file in filenames:
arquivo = path.join(PATH, file)
output = path.join(OUTPUT, file)

print('XML: ' + file)
print(base.ImprimirXml.imprimir(caminho_xml=arquivo, output_dir=output))
38 changes: 16 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
[testenv:bootstrap]
deps =
jinja2
matrix
tox
skip_install = true
commands =
python ci/bootstrap.py
passenv =
*
; a generative tox configuration, see: https://tox.readthedocs.io/en/latest/config.html#generative-envlist

[tox]
envlist =
clean,
check,
docs,
{py36,py37,py38,pypy,pypy3},
{py37,py38,py39,py310},
report
ignore_basepython_conflict = true

[testenv]
basepython =
pypy: {env:TOXPYTHON:pypy}
pypy3: {env:TOXPYTHON:pypy3}
py36: {env:TOXPYTHON:python3.6}
{py38,docs,spell}: {env:TOXPYTHON:python3.8}
{py39,docs,spell}: {env:TOXPYTHON:python3.9}
py37: {env:TOXPYTHON:python3.7}
py38: {env:TOXPYTHON:python3.8}
py39: {env:TOXPYTHON:python3.9}
py310: {env:TOXPYTHON:python3.10}
{bootstrap,clean,check,report,codecov}: {env:TOXPYTHON:python3}
setenv =
PYTHONPATH={toxinidir}/tests
Expand All @@ -36,25 +25,29 @@ passenv =
usedevelop = false
deps =
pytest
pytest-travis-fold
pytest-cov

commands =
{posargs:pytest --cov --cov-report=term-missing -vv tests}

[testenv:bootstrap]
deps =
jinja2
matrix
tox
skip_install = true
commands =
python ci/bootstrap.py

[testenv:check]
deps =
docutils
check-manifest
flake8
readme-renderer
pygments
isort
skip_install = true
commands =
python setup.py check --strict --metadata --restructuredtext
python setup.py check --strict --metadata --restructuredtext -vv
check-manifest {toxinidir}
flake8 src tests setup.py
isort --verbose --check-only --diff --recursive src tests setup.py

[testenv:spell]
setenv =
Expand All @@ -80,6 +73,7 @@ deps =
codecov
skip_install = true
commands =
coverage xml --ignore-errors
codecov []

[testenv:report]
Expand Down

0 comments on commit 3c848ee

Please sign in to comment.