From 047a4c47478a7e41278f13fbb7489c54c28c8805 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 18 Dec 2022 16:45:09 -0700 Subject: [PATCH 1/8] ci: Test on windows --- .github/workflows/python-test.yml | 34 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 7694a92..d70f29b 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -18,18 +18,24 @@ jobs: strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + platform: [ubuntu-latest, windows-latest] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install -r requirements.txt -e ".[dev]" - - name: Test with pytest - run: | - # remove '.' in python-version and prepend with 'py' to get the correct tox env - tox -e py$(echo ${{ matrix.python-version }} | sed 's/\.//g') + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt -e ".[dev]" + python -m pip install --pre tox-gh-actions + - name: Test with pytest + run: | + # remove '.' in python-version and prepend with 'py' to get the correct tox env + tox -e py$(echo ${{ matrix.python-version }} | sed 's/\.//g') + env: + PLATFORM: ${{ matrix.platform }} + From 5445fdf8e447bb793ad73c0dac9bc2499e7c02f1 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 18 Dec 2022 16:51:47 -0700 Subject: [PATCH 2/8] Update python-test.yml --- .github/workflows/python-test.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index d70f29b..d4e9dce 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -13,12 +13,11 @@ on: - main jobs: - build: + build-ubuntu: runs-on: ubuntu-latest strategy: matrix: - platform: [ubuntu-latest, windows-latest] python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: @@ -36,6 +35,22 @@ jobs: run: | # remove '.' in python-version and prepend with 'py' to get the correct tox env tox -e py$(echo ${{ matrix.python-version }} | sed 's/\.//g') - env: - PLATFORM: ${{ matrix.platform }} + build-windows: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.7" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt -e ".[dev]" + python -m pip install --pre tox-gh-actions + - name: Test with pytest + run: tox + env: + PLATFORM: windows-latest From 01a028cb8741b2ea0db563234e473ad5be285206 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 18 Dec 2022 16:57:30 -0700 Subject: [PATCH 3/8] Test removing wcwidth tests --- tests/test_convert.py | 47 ------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/tests/test_convert.py b/tests/test_convert.py index 3030cd6..0e61349 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -258,50 +258,3 @@ def test_multiline_cells(): assert text == expected -def test_east_asian_wide_characters_and_zero_width_wcwidth(): - # using wcwidth.wcswidth() to count the number of characters - text = t2a( - header=["#\u200b", "🦁", "🦡", "🦅", "🐍"], - body=[["💻", "✅", "✅", "❌", "❌"]], - footer=["🥞", "日", "月", "火", "水"], - first_col_heading=True, - ) - text2 = t2a( - header=["#\u200b", "🦁", "🦡", "🦅", "🐍"], - body=[["💻", "✅", "✅", "❌", "❌"]], - footer=["🥞", "日", "月", "火", "水"], - first_col_heading=True, - use_wcwidth=True, - ) - expected = ( - "╔════╦═══════════════════╗\n" - "║ #​ ║ 🦁 🦡 🦅 🐍 ║\n" - "╟────╫───────────────────╢\n" - "║ 💻 ║ ✅ ✅ ❌ ❌ ║\n" - "╟────╫───────────────────╢\n" - "║ 🥞 ║ 日 月 火 水 ║\n" - "╚════╩═══════════════════╝" - ) - assert text == expected - assert text2 == expected - - -def test_east_asian_wide_characters_and_zero_width_no_wcwidth(): - # using len() to count the number of characters - text = t2a( - header=["#\u200b", "🦁", "🦡", "🦅", "🐍"], - body=[["💻", "✅", "✅", "❌", "❌"]], - footer=["🥞", "日", "月", "火", "水"], - first_col_heading=True, - use_wcwidth=False, - ) - expected = ( - "╔════╦═══════════════╗\n" - "║ #​ ║ 🦁 🦡 🦅 🐍 ║\n" - "╟────╫───────────────╢\n" - "║ 💻 ║ ✅ ✅ ❌ ❌ ║\n" - "╟────╫───────────────╢\n" - "║ 🥞 ║ 日 月 火 水 ║\n" - "╚════╩═══════════════╝" - ) - assert text == expected From 6d8b1cd054966befe8827e1dd6b32bfdd9d7b3c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 18 Dec 2022 23:57:39 +0000 Subject: [PATCH 4/8] style: auto fixes from pre-commit hooks --- tests/test_convert.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_convert.py b/tests/test_convert.py index 0e61349..55a3142 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -256,5 +256,3 @@ def test_multiline_cells(): "╚═══════════════════════════════════════════╝" ) assert text == expected - - From e8c76bb03d3d76a55cc5761fe7ca2370bfa65cc6 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 18 Dec 2022 17:05:01 -0700 Subject: [PATCH 5/8] Set encoding type in setup --- setup.py | 6 +++--- tests/test_convert.py | 49 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 0b3faa6..d18c352 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def version(): version = "" - with open("table2ascii/__init__.py") as f: + with open("table2ascii/__init__.py", encoding="utf-8") as f: version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE) if not version: raise RuntimeError("version is not set") @@ -18,7 +18,7 @@ def long_description(): # check if README.md exists if not os.path.exists("README.md"): return "" - with open("README.md", "r") as fh: + with open("README.md", "r", encoding="utf-8") as fh: return fh.read() @@ -26,7 +26,7 @@ def requirements(): # check if requirements.txt exists if not os.path.exists("requirements.txt"): return [] - with open("requirements.txt") as f: + with open("requirements.txt", encoding="utf-8") as f: return f.read().splitlines() diff --git a/tests/test_convert.py b/tests/test_convert.py index 55a3142..3030cd6 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -256,3 +256,52 @@ def test_multiline_cells(): "╚═══════════════════════════════════════════╝" ) assert text == expected + + +def test_east_asian_wide_characters_and_zero_width_wcwidth(): + # using wcwidth.wcswidth() to count the number of characters + text = t2a( + header=["#\u200b", "🦁", "🦡", "🦅", "🐍"], + body=[["💻", "✅", "✅", "❌", "❌"]], + footer=["🥞", "日", "月", "火", "水"], + first_col_heading=True, + ) + text2 = t2a( + header=["#\u200b", "🦁", "🦡", "🦅", "🐍"], + body=[["💻", "✅", "✅", "❌", "❌"]], + footer=["🥞", "日", "月", "火", "水"], + first_col_heading=True, + use_wcwidth=True, + ) + expected = ( + "╔════╦═══════════════════╗\n" + "║ #​ ║ 🦁 🦡 🦅 🐍 ║\n" + "╟────╫───────────────────╢\n" + "║ 💻 ║ ✅ ✅ ❌ ❌ ║\n" + "╟────╫───────────────────╢\n" + "║ 🥞 ║ 日 月 火 水 ║\n" + "╚════╩═══════════════════╝" + ) + assert text == expected + assert text2 == expected + + +def test_east_asian_wide_characters_and_zero_width_no_wcwidth(): + # using len() to count the number of characters + text = t2a( + header=["#\u200b", "🦁", "🦡", "🦅", "🐍"], + body=[["💻", "✅", "✅", "❌", "❌"]], + footer=["🥞", "日", "月", "火", "水"], + first_col_heading=True, + use_wcwidth=False, + ) + expected = ( + "╔════╦═══════════════╗\n" + "║ #​ ║ 🦁 🦡 🦅 🐍 ║\n" + "╟────╫───────────────╢\n" + "║ 💻 ║ ✅ ✅ ❌ ❌ ║\n" + "╟────╫───────────────╢\n" + "║ 🥞 ║ 日 月 火 水 ║\n" + "╚════╩═══════════════╝" + ) + assert text == expected From 1eb95d2455b0e7faa15a9d6cf1e7bbe6681790c3 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 18 Dec 2022 17:07:25 -0700 Subject: [PATCH 6/8] Update setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index d18c352..d63b962 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def version(): version = "" - with open("table2ascii/__init__.py", encoding="utf-8") as f: + with open("table2ascii/__init__.py") as f: version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE) if not version: raise RuntimeError("version is not set") @@ -18,7 +18,7 @@ def long_description(): # check if README.md exists if not os.path.exists("README.md"): return "" - with open("README.md", "r", encoding="utf-8") as fh: + with open("README.md", "r") as fh: return fh.read() From af3f77fd31f05425d8c1cb5d646e383979f6bc6d Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 18 Dec 2022 17:08:54 -0700 Subject: [PATCH 7/8] Update setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index d63b962..69b0dd0 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def long_description(): # check if README.md exists if not os.path.exists("README.md"): return "" - with open("README.md", "r") as fh: + with open("README.md", "r", encoding="utf-8") as fh: return fh.read() @@ -26,7 +26,7 @@ def requirements(): # check if requirements.txt exists if not os.path.exists("requirements.txt"): return [] - with open("requirements.txt", encoding="utf-8") as f: + with open("requirements.txt") as f: return f.read().splitlines() From ee20218f5b5879227e9562a96c68a96439837062 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 18 Dec 2022 17:10:01 -0700 Subject: [PATCH 8/8] Update python-test.yml --- .github/workflows/python-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index d4e9dce..45adbf5 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -13,7 +13,7 @@ on: - main jobs: - build-ubuntu: + test-ubuntu: runs-on: ubuntu-latest strategy: @@ -36,7 +36,7 @@ jobs: # remove '.' in python-version and prepend with 'py' to get the correct tox env tox -e py$(echo ${{ matrix.python-version }} | sed 's/\.//g') - build-windows: + test-windows: runs-on: windows-latest steps: