Fixed tests
This commit is contained in:
parent
c67963fcb9
commit
bb291b3d74
|
@ -6,3 +6,4 @@ node_modules
|
||||||
*.egg-info
|
*.egg-info
|
||||||
*.pyc
|
*.pyc
|
||||||
*.tgz
|
*.tgz
|
||||||
|
Pipfile.lock
|
4
Makefile
4
Makefile
|
@ -31,9 +31,7 @@ clean-pyc: ## remove Python file artifacts
|
||||||
find . -name '__pycache__' -exec rm -fr {} +
|
find . -name '__pycache__' -exec rm -fr {} +
|
||||||
|
|
||||||
clean-test: ## remove test and coverage artifacts
|
clean-test: ## remove test and coverage artifacts
|
||||||
rm -fr .tox/
|
|
||||||
rm -f .coverage
|
rm -f .coverage
|
||||||
rm -fr htmlcov/
|
|
||||||
rm -fr .pytest_cache
|
rm -fr .pytest_cache
|
||||||
|
|
||||||
lint: ## check style with flake8
|
lint: ## check style with flake8
|
||||||
|
@ -42,7 +40,7 @@ lint: ## check style with flake8
|
||||||
flake8 gitinspector tests --max-line-length=120
|
flake8 gitinspector tests --max-line-length=120
|
||||||
|
|
||||||
test: ## run tests quickly with the default Python
|
test: ## run tests quickly with the default Python
|
||||||
py.test
|
pytest
|
||||||
|
|
||||||
test-debug: ## run tests with debugging enabled
|
test-debug: ## run tests with debugging enabled
|
||||||
LOGLEVEL=debug; py.test -s --pdb
|
LOGLEVEL=debug; py.test -s --pdb
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
[[source]]
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
name = "pypi"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
pytest = "*"
|
||||||
|
flake8 = "*"
|
||||||
|
autopep8 = "*"
|
||||||
|
black = "*"
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.8"
|
||||||
|
|
||||||
|
[pipenv]
|
||||||
|
allow_prereleases = true
|
|
@ -20,7 +20,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest2
|
import unittest
|
||||||
import gitinspector.comment
|
import gitinspector.comment
|
||||||
|
|
||||||
def __test_extension__(commented_file, extension):
|
def __test_extension__(commented_file, extension):
|
||||||
|
@ -32,19 +32,18 @@ def __test_extension__(commented_file, extension):
|
||||||
is_inside_comment = False
|
is_inside_comment = False
|
||||||
comment_counter = 0
|
comment_counter = 0
|
||||||
for i in tex:
|
for i in tex:
|
||||||
i = i.decode("utf-8", "replace")
|
|
||||||
(_, is_inside_comment) = gitinspector.comment.handle_comment_block(is_inside_comment, extension, i)
|
(_, is_inside_comment) = gitinspector.comment.handle_comment_block(is_inside_comment, extension, i)
|
||||||
if is_inside_comment or gitinspector.comment.is_comment(extension, i):
|
if is_inside_comment or gitinspector.comment.is_comment(extension, i):
|
||||||
comment_counter += 1
|
comment_counter += 1
|
||||||
|
|
||||||
return comment_counter
|
return comment_counter
|
||||||
|
|
||||||
class TexFileTest(unittest2.TestCase):
|
class TexFileTest(unittest.TestCase):
|
||||||
def test(self):
|
def test(self):
|
||||||
comment_counter = __test_extension__("/resources/commented_file.tex", "tex")
|
comment_counter = __test_extension__("/resources/commented_file.tex", "tex")
|
||||||
self.assertEqual(comment_counter, 30)
|
self.assertEqual(comment_counter, 30)
|
||||||
|
|
||||||
class CppFileTest(unittest2.TestCase):
|
class CppFileTest(unittest.TestCase):
|
||||||
def test(self):
|
def test(self):
|
||||||
comment_counter = __test_extension__("/resources/commented_file.cpp", "cpp")
|
comment_counter = __test_extension__("/resources/commented_file.cpp", "cpp")
|
||||||
self.assertEqual(comment_counter, 25)
|
self.assertEqual(comment_counter, 25)
|
||||||
|
|
Loading…
Reference in New Issue