Skip to content

Commit

Permalink
add coveralls and flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Apkawa committed Oct 17, 2017
1 parent 7a3f0bf commit e4d340e
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ python:
- "3.6"
- "nightly"
install: pip install tox-travis
script: tox
script: tox -v --cov xlsx2html --cov-report term-missing
after_success:
- coveralls
4 changes: 4 additions & 0 deletions package_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
six
openpyxl>=2.4.8
babel>=2.3.4
pypandoc
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pytest]
python_files=tests.py test_*.py
addopts = --ignore=node_modules --ignore=static -r fesxXR
addopts = --ignore=node_modules --ignore=static -r fesxXR --doctest-modules

python_paths = ./

Expand Down
7 changes: 2 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
six
openpyxl>=2.4.8
babel>=2.3.4
pypandoc
twine
-r package_requirements.txt
-r test_requirements.txt
3 changes: 2 additions & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
tox>=2.3
pytest
pytest
flake8
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-

10 changes: 4 additions & 6 deletions tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,25 @@

import os
from unittest import TestCase
from xlsx2html.core import xlsx2html

FIXTURES_ROOT = os.path.join(os.path.dirname(__file__), 'fixtures')

from xlsx2html.core import xlsx2html


class XLS2HTMLTestCase(TestCase):
maxDiff = None

def setUp(self):
self.xlsx_file = os.path.join(FIXTURES_ROOT, 'example.xlsx')
self.expect_result = open(os.path.join(FIXTURES_ROOT, 'example.html')).read()
self.expect_result = open(
os.path.join(FIXTURES_ROOT, 'example.html')
).read()
self.tmp_file = tempfile.mktemp(suffix='xls2html_')

def test_xls2html(self):
xlsx2html(self.xlsx_file, self.tmp_file)
result_html = open(self.tmp_file).read()

# expect_result_file = open(os.path.join(FIXTURES_ROOT, 'example.html'), 'wb')
# expect_result_file.write(result_html)

self.assertEqual(result_html, self.expect_result)

def tearDown(self):
Expand Down
15 changes: 8 additions & 7 deletions tests/test_format.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# coding: utf-8
from __future__ import unicode_literals

import tempfile

import os
from unittest import TestCase
from xlsx2html.format import format_decimal

FIXTURES_ROOT = os.path.join(os.path.dirname(__file__), 'fixtures')

from xlsx2html.format import format_decimal


class FormatTestCase(TestCase):
maxDiff = None

def setUp(self):
pass

def test_currency_format(self):
format = u'#,##0.00\\ [$\u0440.-419];\\-#,##0.00\\ [$\u0440.-419]'
self.assertEqual(format_decimal(1000, format=format, locale='ru'), '1\xa0000,00 р.')
self.assertEqual(format_decimal(-1000, format=format, locale='ru'), '-1\xa0000,00 р.')

self.assertEqual(
format_decimal(1000, format=format, locale='ru'),
'1\xa0000,00 р.')
self.assertEqual(
format_decimal(-1000, format=format, locale='ru'),
'-1\xa0000,00 р.')
21 changes: 15 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@ skip_missing_interpreters=true
envlist =
py27
py3{3,4,5,6,7}
flake8


[testenv]
changedir={toxinidir}/tests/
deps =
pytest

six
openpyxl>=2.4.8
babel>=2.5.1
-r{toxinidir}/package_requirements.txt
-r{toxinidir}/test_requirements.txt

commands =
py.test --basetemp={envtmpdir} {posargs}
py.test --basetemp={envtmpdir} {posargs}

[testenv:flake8]
commands = flake8 .
deps = flake8

[flake8]
exclude =
.git,
.tox,
build,
dist

0 comments on commit e4d340e

Please sign in to comment.