diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 550be1c..1287ff5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,15 +27,33 @@ jobs: python-version: ${{ matrix.python-version }} allow-prereleases: true - - name: Install dependencies + - name: Install dependencies (macOS) if: runner.os == 'macOS' run: brew install libiconv + - name: Install dependencies (Windows) + if: runner.os == 'Windows' + run: | + curl -L -o libiconv.zip https://github.com/pffang/libiconv-for-Windows/releases/download/1.18/libiconv-for-Windows_prebuilt.zip + Expand-Archive libiconv.zip -DestinationPath libiconv + + $ppath = python -c "import sys; print(sys.base_prefix)" + Copy-Item "libiconv\iconv.h" "$ppath\include\" + New-Item -ItemType Directory -Force -Path "$ppath\libs" + Copy-Item "libiconv\x64\Release\libiconv.lib" "$ppath\libs\iconv.lib" + Copy-Item "libiconv\x64\Release\libiconv.dll" "$ppath\Lib\site-packages\" + - name: Install package run: | python -m pip install --upgrade pip pip install -e . - name: Run tests + if: runner.os != 'Windows' + run: python -m unittest -v + + - name: Run tests (Windows) + if: runner.os == 'Windows' run: | + Copy-Item "libiconv\x64\Release\libiconv.dll" "libiconv.dll" python -m unittest -v diff --git a/test_iconvcodec.py b/test_iconvcodec.py index 6a38963..aaa5bc9 100644 --- a/test_iconvcodec.py +++ b/test_iconvcodec.py @@ -1,9 +1,11 @@ import unittest import iconvcodec import codecs +import sys class TestIconvcodecModule(unittest.TestCase): + @unittest.skipUnless(sys.platform.startswith("linux"), "Linux only test") def test_encode(self): bytestring = "Hallo".encode("T.61") self.assertEqual(bytestring, b"Hallo") @@ -11,12 +13,17 @@ def test_encode(self): def test_encode_with_long_out(self): """Edge case where output has more bytes than input as utf-8""" bytestring = "™".encode("ASCII//TRANSLIT") - self.assertEqual(bytestring, b"(TM)") + if sys.platform.startswith("linux"): + self.assertEqual(bytestring, b"(TM)") + else: + self.assertEqual(bytestring, b"TM") + @unittest.skipUnless(sys.platform.startswith("linux"), "Linux only test") def test_decode(self): string = b"Hallo".decode("T.61") self.assertEqual(string, "Hallo") + @unittest.skipUnless(sys.platform.startswith("linux"), "Linux only test") def test_transliterate(self): string = "abc ß α € àḃç" bytestring = string.encode("ASCII//TRANSLIT") @@ -30,6 +37,7 @@ def test_incremental_encode(self): self.assertEqual(first, b"Foo") self.assertEqual(second, b"bar") + @unittest.skipUnless(sys.platform.startswith("linux"), "Linux only test") def test_incremental_decode(self): decoder = codecs.getincrementaldecoder("UCS2")() first = decoder.decode(b"\x41")