Skip to content
Merged
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
20 changes: 19 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion test_iconvcodec.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
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")

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")
Expand All @@ -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")
Expand Down