From b486182ed0517d2a2c94709222dd0567b7331ffd Mon Sep 17 00:00:00 2001 From: matheuscas Date: Tue, 16 Jan 2024 18:06:35 -0300 Subject: [PATCH] refactor: do a small refactor on the tests --- ...lculation_tests.py => test_calculation.py} | 31 ++++++------------- tests/{cnpj_tests.py => test_cnpj.py} | 4 --- tests/{cpf_tests.py => test_cpf.py} | 4 --- tests/{cpfcnpj_tests.py => test_cpfcnpj.py} | 0 tests/{gen_test.py => test_gen.py} | 0 5 files changed, 9 insertions(+), 30 deletions(-) rename tests/{calculation_tests.py => test_calculation.py} (76%) rename tests/{cnpj_tests.py => test_cnpj.py} (96%) rename tests/{cpf_tests.py => test_cpf.py} (96%) rename tests/{cpfcnpj_tests.py => test_cpfcnpj.py} (100%) rename tests/{gen_test.py => test_gen.py} (100%) diff --git a/tests/calculation_tests.py b/tests/test_calculation.py similarity index 76% rename from tests/calculation_tests.py rename to tests/test_calculation.py index a9e9712..e9c67f8 100644 --- a/tests/calculation_tests.py +++ b/tests/test_calculation.py @@ -1,19 +1,9 @@ -import sys import unittest -if sys.version[0] == '2': - from pycpfcnpj import calculation as calc -else: - import os - import inspect - currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) - parentdir = os.path.dirname(currentdir) - sys.path.insert(0,parentdir) - import pycpfcnpj.calculation as calc +from pycpfcnpj import calculation as calc class CalculationTests(unittest.TestCase): - """docstring for CalculationTests""" def setUp(self): @@ -33,16 +23,16 @@ def test_cpf_calculate_first_digit_false(self): def test_cpf_calculate_second_digit_true(self): updated_cpf_number = self.first_part_cpf_number + \ - calc.calculate_first_digit( - self.first_part_cpf_number) + calc.calculate_first_digit( + self.first_part_cpf_number) correct_second_digit = '5' self.assertEqual(correct_second_digit, calc.calculate_second_digit(updated_cpf_number)) def test_cpf_calculate_second_digit_false(self): updated_cpf_number = self.first_part_cpf_number + \ - calc.calculate_first_digit( - self.first_part_cpf_number) + calc.calculate_first_digit( + self.first_part_cpf_number) incorrect_second_digit = '7' self.assertNotEqual(incorrect_second_digit, calc.calculate_second_digit(updated_cpf_number)) @@ -61,19 +51,16 @@ def test_cnpj_calculate_first_digit_false(self): def test_cnpj_calculate_second_digit_true(self): correct_second_digit = '1' updated_cnpj_number = self.first_part_cnpj_number + \ - calc.calculate_first_digit( - self.first_part_cnpj_number) + calc.calculate_first_digit( + self.first_part_cnpj_number) self.assertEqual(correct_second_digit, calc.calculate_second_digit(updated_cnpj_number)) def test_cnpj_calculate_second_digit_false(self): correct_second_digit = '2' updated_cnpj_number = self.first_part_cnpj_number + \ - calc.calculate_first_digit( - self.first_part_cnpj_number) + calc.calculate_first_digit( + self.first_part_cnpj_number) self.assertNotEqual(correct_second_digit, calc.calculate_second_digit(updated_cnpj_number)) - -if __name__ == '__main__': - unittest.main(verbosity=2) diff --git a/tests/cnpj_tests.py b/tests/test_cnpj.py similarity index 96% rename from tests/cnpj_tests.py rename to tests/test_cnpj.py index 3fa629d..64d4bd9 100644 --- a/tests/cnpj_tests.py +++ b/tests/test_cnpj.py @@ -39,7 +39,3 @@ def test_validate_cnpj_with_alphabetic_characters(self): def test_validate_cnpj_with_special_characters(self): self.assertFalse(cnpj.validate(self.invalid_cnpj_with_special_character)) - - -if __name__ == "__main__": - unittest.main(verbosity=2) diff --git a/tests/cpf_tests.py b/tests/test_cpf.py similarity index 96% rename from tests/cpf_tests.py rename to tests/test_cpf.py index 7c2ad34..f3cc4f9 100644 --- a/tests/cpf_tests.py +++ b/tests/test_cpf.py @@ -51,7 +51,3 @@ def test_validate_cpf_with_alphabetic_characters(self): def test_validate_cpf_with_special_characters(self): self.assertFalse(cpf.validate(self.invalid_cpf_with_special_character)) - - -if __name__ == "__main__": - unittest.main(verbosity=2) diff --git a/tests/cpfcnpj_tests.py b/tests/test_cpfcnpj.py similarity index 100% rename from tests/cpfcnpj_tests.py rename to tests/test_cpfcnpj.py diff --git a/tests/gen_test.py b/tests/test_gen.py similarity index 100% rename from tests/gen_test.py rename to tests/test_gen.py