Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- uses: ./.github/actions/setup-python
- name: pytest
working-directory: ./python
run: bash run_unittests.sh
run: pytest
# mypy:
# timeout-minutes: 10
# runs-on: ubuntu-latest
Expand Down
9 changes: 2 additions & 7 deletions python/calculator_cli_app/src/application.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
from args_validation import __validate__
from calculation_query import CalculationQuery
from data_type_conversion import __to_int_with_rescue__
import sys
sys.path.append('./calculator_cli_app/src')
sys.path.append('./calculator_cli_app/src/lib')
sys.path.append('./calculator_cli_app/src/queries')
sys.path.append('./calculator_cli_app/src/validations')
from calculation_query import CalculationQuery
from args_validation import __validate__


class Application:
Expand Down
14 changes: 12 additions & 2 deletions python/calculator_cli_app/test/queries/test_calculation_query.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
from calculation_query import CalculationQuery
import unittest
import sys
from io import StringIO
import glob
import os
import shutil
sys.path.append('./src/queries')
from calculation_query import CalculationQuery

# Add src paths relative to this test file's location
test_dir = os.path.dirname(os.path.abspath(__file__))
module_root = os.path.dirname(os.path.dirname(test_dir))
src_paths = [
os.path.join(module_root, 'src', 'queries'),
os.path.join(module_root, 'src')
]
for src_path in src_paths:
if src_path not in sys.path:
sys.path.insert(0, src_path)


class TestCalculationQuery(unittest.TestCase):
Expand Down
29 changes: 24 additions & 5 deletions python/calculator_cli_app/test/test_application.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
from application import Application
import unittest
import sys
from io import StringIO
import glob
import os
import shutil
sys.path.append('./src')
sys.path.append('./src/lib')
sys.path.append('./src/queries')
sys.path.append('./src/validations')
from application import Application

# Add src paths relative to this test file's location
test_dir = os.path.dirname(os.path.abspath(__file__))
module_root = os.path.dirname(test_dir)
src_paths = [
os.path.join(module_root, 'src'),
os.path.join(module_root, 'src', 'lib'),
os.path.join(module_root, 'src', 'queries'),
os.path.join(module_root, 'src', 'validations')
]

# Remove cached modules to ensure fresh import
for module in list(sys.modules.keys()):
if module in [
'application',
'data_type_conversion',
'calculation_query',
'args_validation']:
del sys.modules[module]

for src_path in src_paths:
if src_path not in sys.path:
sys.path.insert(0, src_path)


class TestApplication(unittest.TestCase):
Expand Down
5 changes: 4 additions & 1 deletion python/fibonacci_sequence/src/fibonacci.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
__all__ = ['fibonacci']


def fibonacci(init_num, iter):
current_num = init_num
next_num = current_num + 1
result = list()
for num in range(init_num, iter + init_num):
for _ in range(init_num, iter + init_num):
result.append(current_num)
current_num, next_num = next_num, current_num + next_num
return result
10 changes: 8 additions & 2 deletions python/fibonacci_sequence/test/test_fibonacci.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from fibonacci import *
import unittest
import sys
import glob
import os
import shutil
sys.path.append('./src')
from fibonacci import *

# Add src path relative to this test file's location
test_dir = os.path.dirname(os.path.abspath(__file__))
module_root = os.path.dirname(test_dir)
src_path = os.path.join(module_root, 'src')
if src_path not in sys.path:
sys.path.insert(0, src_path)


class TestFibonacci(unittest.TestCase):
Expand Down
3 changes: 3 additions & 0 deletions python/fizzbuzz/src/fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
__all__ = ['fizzbuzz_in_if', 'fizzbuzz_in_ternary']


def fizzbuzz_in_if(num):
if num % 3 == 0 and num % 5 == 0:
result = 'FizzBuzz'
Expand Down
10 changes: 8 additions & 2 deletions python/fizzbuzz/test/test_fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from fizzbuzz import *
import unittest
import sys
import glob
import os
import shutil
sys.path.append('./src')
from fizzbuzz import *

# Add src path relative to this test file's location
test_dir = os.path.dirname(os.path.abspath(__file__))
module_root = os.path.dirname(test_dir)
src_path = os.path.join(module_root, 'src')
if src_path not in sys.path:
sys.path.insert(0, src_path)


class TestFizzBuzz(unittest.TestCase):
Expand Down
6 changes: 3 additions & 3 deletions python/letter_inspection/test/test_application.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import unittest
import sys
import glob
import os
import shutil
sys.path.append('./src')
from application import Application


Expand All @@ -16,9 +14,11 @@ def setUp(self):
self.pattern_1 = Application(str_1=str_1, str_2=str_2)
self.pattern_2 = Application(str_1=str_1, str_2=str_3)
self.pattern_3 = Application(str_1=str_1, str_2=str_4)
test_dir = os.path.dirname(os.path.abspath(__file__))
module_root = os.path.dirname(test_dir)
self.pycaches = glob.glob(
os.path.join(
'.',
module_root,
'**',
'__pycache__'),
recursive=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from application import Application
import unittest
import sys
import glob
import os
import shutil

# Add src path relative to this test file's location
test_dir = os.path.dirname(os.path.abspath(__file__))
module_root = os.path.dirname(test_dir)
src_path = os.path.join(module_root, 'src')

# Remove cached modules to ensure fresh import
for mod in list(sys.modules.keys()):
if mod == 'application':
del sys.modules[mod]

if src_path not in sys.path:
sys.path.insert(0, src_path)


class TestApplication(unittest.TestCase):
def setUp(self):
str_1 = 'hogefoobar'
str_2 = 'abefghooor'
str_3 = 'hoge'
str_4 = 'piyopoopee'
self.pattern_1 = Application(str_1=str_1, str_2=str_2)
self.pattern_2 = Application(str_1=str_1, str_2=str_3)
self.pattern_3 = Application(str_1=str_1, str_2=str_4)
self.pycaches = glob.glob(
os.path.join(
'.',
'**',
'__pycache__'),
recursive=True)

def tearDown(self):
for pycache in self.pycaches:
if os.path.exists(pycache):
shutil.rmtree(pycache)


class TestRegularCase(TestApplication):
def test_exactly_equal_size_and_included_1(self):
self.assertTrue(self.pattern_1.exactly_equal_size_and_included())


class TestIrregularCase(TestApplication):
pass


class TestCase1(TestIrregularCase):
def test_exactly_equal_size_and_included_2(self):
self.assertFalse(self.pattern_2.exactly_equal_size_and_included())


class TestCase1(TestIrregularCase):
def test_exactly_equal_size_and_included_3(self):
self.assertFalse(self.pattern_3.exactly_equal_size_and_included())


if __name__ == '__main__':
unittest.main()
3 changes: 3 additions & 0 deletions python/nabeatsu/src/nabeatsu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
__all__ = ['go_crazy_in_if', 'go_crazy_in_ternary']


def go_crazy_in_if(num):
if num % 3 == 0 or '3' in str(num):
# Express the status of 'crazy' with '!'
Expand Down
10 changes: 8 additions & 2 deletions python/nabeatsu/test/test_nabeatsu.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from nabeatsu import *
import unittest
import sys
import glob
import os
import shutil
sys.path.append('./src')
from nabeatsu import *

# Add src path relative to this test file's location
test_dir = os.path.dirname(os.path.abspath(__file__))
module_root = os.path.dirname(test_dir)
src_path = os.path.join(module_root, 'src')
if src_path not in sys.path:
sys.path.insert(0, src_path)


class TestNabeatsu(unittest.TestCase):
Expand Down
11 changes: 11 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tool.mypy]
python_version = "3.14"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true

[tool.pytest.ini_options]
# Configure pytest to properly handle module discovery
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
8 changes: 0 additions & 8 deletions python/run_unittests.sh

This file was deleted.

Loading