Repository: i3thuan5/TauPhahJi-Command (language: python)

Issue:
加試驗



Discussion / hints:

Fix patch:
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..85e004a
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,17 @@
+dist: jammy
+language: python
+python:
+- '3.10'
+branches:
+  only:
+  - master
+jobs:
+  include:
+  - name: "test"
+    env: TOX_ENV=test
+  - name: "flake8"
+    env: TOX_ENV=flake8
+install:
+- pip install tox
+script:
+- tox -e $TOX_ENV
diff --git a/README.md b/README.md
index 20fa01b..413154c 100644
--- a/README.md
+++ b/README.md
@@ -12,12 +12,12 @@ pip install https://github.com/i3thuan5/TauPhahJi-Command/archive/refs/heads/mas
 >>> from tauphahji_cmd import tàuphahjī
 >>> tàuphahjī('gau5 tsa2\nlâi-khì.')
 {
-  ## Tsuân-pōo
+  # Tsuân-pōo
   'kiatko': [
     {'漢字': '𠢕早', 'KIP': 'gâu-tsá', '分詞': '𠢕-早｜gâu-tsá'},
     {'漢字': '來去。', 'KIP': 'lâi-khì.', '分詞': '來-去｜lâi-khì 。｜.'}
   ],
-  ## Thâu-tsi̍t-kú
+  # Thâu-tsi̍t-kú
   '漢字': '𠢕早',
   'KIP': 'gâu-tsá',
   '分詞': '𠢕-早｜gâu-tsá'
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..83a3e1b
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,24 @@
+[project]
+name = "TauPhahJi-Command"
+version = "0.1.0"
+
+[metadata]
+license_file = "LICENSE"
+
+[build-system]
+requires = [
+    "setuptools >= 35.0.2",
+    "setuptools_scm >= 2.0.0, <3"
+]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools]
+package-dir = {"tauphahji_cmd" = "tauphahji_cmd"}
+
+[tool.setuptools.packages.find]
+where = ["."]
+include = ["tauphahji_cmd"]
+exclude = ["tshi"]
+
+[bdist_wheel]
+universal = 1
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 60bd34d..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-[bdist_wheel]
-universal = 1
-
-[metadata]
-license_file = LICENSE
\ No newline at end of file
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 16737e8..0000000
--- a/setup.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import setuptools
-from distutils.core import setup
-
-版本 = '0.1.0'
-
-setup(
-    name='Tau-Phah-Ji-Command',
-    version=版本,
-    author='薛丞宏',
-    author_email='ihcaoe@gmail.com',
-    url='https://github.com/i3thuan5/Tau-Phah-Ji-Command',
-    py_modules=['tauphahji_cmd'],
-    description='用指令叫鬥拍字',
-    keywords=[
-        '語料庫', '語言合成', '機器翻譯',
-        'Taiwan', 'Natural Language', 'Corpus',
-        'Text to Speech', 'TTS',
-        'Machine Translateion',
-    ],
-    classifiers=[
-        'Development Status :: 3 - Alpha',
-        'Operating System :: Unix',
-        'Programming Language :: Python :: 3.4',
-        'Programming Language :: Python :: 3.5',
-        'Topic :: Scientific/Engineering',
-        'Topic :: Scientific/Engineering :: Information Analysis',
-        'Topic :: Text Processing',
-        'Topic :: Text Processing :: Linguistic',
-        "License :: OSI Approved :: MIT License",
-    ],
-    setup_requires=['wheel']
-)
diff --git a/tauphahji_cmd.py b/tauphahji_cmd/__init__.py
similarity index 98%
rename from tauphahji_cmd.py
rename to tauphahji_cmd/__init__.py
index be20b03..7c9c2fe 100644
--- a/tauphahji_cmd.py
+++ b/tauphahji_cmd/__init__.py
@@ -23,6 +23,7 @@ def tàuphahjī(漢羅, **tshamsoo):
     )
 
     responseStr = conn.getresponse().read().decode('utf-8')
+    conn.close()
     return json.loads(responseStr)
 
 
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..c3ea0f1
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,12 @@
+[tox]
+isolated_build = True
+
+[testenv:flake8]
+deps = 
+    flake8
+commands =
+    flake8 . --exclude=venv/,.tox/ --show-source --count
+
+[testenv:test]
+commands =
+    python -m unittest {posargs}
diff --git a/MANIFEST.in b/tshi/__init__.py
similarity index 100%
rename from MANIFEST.in
rename to tshi/__init__.py


Test patch:
diff --git a/tshi/test_tauphahji.py b/tshi/test_tauphahji.py
new file mode 100644
index 0000000..9acfbc2
--- /dev/null
+++ b/tshi/test_tauphahji.py
@@ -0,0 +1,21 @@
+from tauphahji_cmd import tàuphahjī
+from unittest import TestCase
+
+
+class TauPhahJi(TestCase):
+    def test_kio(self):
+        kiatko = tàuphahjī('gau5 tsa2\nlâi-khì.')
+        self.assertEqual(
+            kiatko,
+            {
+              # Tsuân-pōo
+              'kiatko': [
+                {'漢字': '𠢕早', 'KIP': 'gâu-tsá', '分詞': '𠢕-早｜gâu-tsá'},
+                {'漢字': '來去。', 'KIP': 'lâi-khì.', '分詞': '來-去｜lâi-khì 。｜.'}
+              ],
+              # Thâu-tsi̍t-kú
+              '漢字': '𠢕早',
+              'KIP': 'gâu-tsá',
+              '分詞': '𠢕-早｜gâu-tsá'
+            }
+        )