File: test_parse.py

package info (click to toggle)
python-mt-940 4.30.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,272 kB
  • sloc: python: 1,746; makefile: 201
file content (25 lines) | stat: -rw-r--r-- 630 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pathlib
import pytest
import mt940

_tests_path = pathlib.Path(__file__).parent


@pytest.mark.parametrize(
    'path,encoding', [
        (_tests_path / 'jejik' / 'ing.sta', 'utf-8'),
        (_tests_path / 'self-provided' / 'raphaelm.sta', 'utf-8'),
        (_tests_path / 'betterplace' / 'with_binary_character.sta', 'utf-8'),
    ]
)
def test_non_ascii_parse(path, encoding):
    # Read as binary
    with path.open('rb') as fh:
        data = fh.read()
        data = data.decode(encoding)
        mt940.parse(data)

    # Read as text
    with path.open('r') as fh:
        data = fh.read()
        mt940.parse(data)