|
4 | 4 | import datetime |
5 | 5 | import io |
6 | 6 | import itertools |
| 7 | +import os |
7 | 8 | import string |
8 | 9 | import warnings |
9 | 10 |
|
|
27 | 28 |
|
28 | 29 | import shapefile as shp |
29 | 30 |
|
| 31 | +IN_CI = bool(os.getenv("CI") or os.getenv("GITHUB_ACTIONS")) |
| 32 | + |
30 | 33 | @contextlib.contextmanager |
31 | 34 | def ignore_warnings(category=None): |
32 | 35 | with warnings.catch_warnings(): |
@@ -551,52 +554,39 @@ def test_shx_reader_writer_roundtrip(codes_and_shapes)-> None: |
551 | 554 | } |
552 | 555 |
|
553 | 556 |
|
554 | | -ENCODINGS = [ |
| 557 | +ENCODINGS = [ |
555 | 558 | "ascii", |
556 | 559 | "latin1", |
557 | 560 | "utf-8", |
558 | 561 | "utf-16-be", |
559 | 562 | "utf-16-le", |
560 | | - "utf-16", |
561 | | - "utf-32-be", |
562 | 563 | "utf-32-le", |
563 | | - "cp1252", |
564 | | - "cp1254", |
565 | | - "cp932", |
566 | | - "euc_kr", |
567 | | - "euc_jp", |
568 | | - "mac_iceland", |
569 | | - "cp932", |
570 | | - "shift_jis", |
571 | | - "iso8859_5", |
572 | | - "koi8_r", |
573 | | - "gbk", |
574 | | - "gb18030", |
575 | | - "big5", |
| 564 | + "cp1140", |
576 | 565 | ] |
577 | | -encodings = sampled_from(ENCODINGS) |
578 | | - |
579 | | -# from encodings.aliases import aliases |
580 | | -# encs = set() |
581 | | -# for enc in aliases.values(): |
582 | | -# if enc in encs: |
583 | | -# continue |
584 | | -# try: |
585 | | -# "".encode(enc) |
586 | | -# except UnicodeEncodeError, LookupError: |
587 | | -# continue |
588 | | -# encs.add(enc) |
589 | | -# assert encs == ['utf_16_le', 'iso8859_7', 'cp437', 'iso2022_jp_3', 'shift_jis', 'cp775', 'cp1140', |
| 566 | + |
| 567 | +def _encodings() -> set[str]: |
| 568 | + from encodings.aliases import aliases |
| 569 | + encs = set() |
| 570 | + for enc in aliases.values(): |
| 571 | + if enc in encs: |
| 572 | + continue |
| 573 | + try: |
| 574 | + "".encode(enc) |
| 575 | + except (UnicodeEncodeError, LookupError): |
| 576 | + continue |
| 577 | + encs.add(enc) |
| 578 | + return encs |
| 579 | +# assert _encodings() == {'utf_16_le', 'iso8859_7', 'cp437', 'iso2022_jp_3', 'shift_jis', 'cp775', 'cp1140', |
590 | 580 | # 'cp861', 'iso8859_11', 'iso8859_9', 'euc_jp', 'utf_16', 'cp950', 'mac_cyrillic', 'mac_turkish', 'iso2022_jp_1', 'iso8859_10', |
591 | 581 | # 'iso2022_jp_2004', 'cp866', 'mac_greek', 'hz', 'cp1257', 'cp037', 'cp863', 'iso8859_4', 'utf_16_be', 'gb18030', 'cp1250', |
592 | 582 | # 'cp850', 'iso8859_5', 'shift_jisx0213', 'iso8859_8', 'cp273', 'euc_jisx0213', 'cp932', 'cp862', 'tis_620', 'cp1125', 'koi8_r', |
593 | 583 | # 'cp874', 'cp1026', 'cp1252', 'cp858', 'cp865', 'gb2312', 'iso8859_15', 'cp857', 'cp860', 'iso2022_jp', 'iso2022_jp_ext', |
594 | 584 | # 'ascii', 'cp1254', 'cp424', 'cp855', 'hp_roman8', 'mac_latin2', 'euc_jis_2004', 'euc_kr', 'cp1256', 'shift_jis_2004', |
595 | 585 | # 'utf_32_le', 'gbk', 'cp869', 'iso8859_13', 'iso8859_3', 'big5', 'cp1258', 'cp1253', 'latin_1', 'cp864', 'utf_8', |
596 | 586 | # 'iso2022_kr', 'cp1251', 'cp1255', 'mac_iceland', 'kz1048', 'iso8859_14', 'utf_32_be', 'ptcp154', 'iso8859_6', 'mac_roman', |
597 | | -# 'utf_32', 'iso2022_jp_2', 'iso8859_16', 'mbcs', 'cp500', 'iso8859_2', 'cp949', 'cp852', 'utf_7', 'big5hkscs', 'johab'] |
| 587 | +# 'utf_32', 'iso2022_jp_2', 'iso8859_16', 'mbcs', 'cp500', 'iso8859_2', 'cp949', 'cp852', 'utf_7', 'big5hkscs', 'johab'} |
598 | 588 |
|
599 | | -# encodings = sampled_from(list(encs)) |
| 589 | +encodings = sampled_from(list(_encodings())) # if IN_CI else ENCODINGS) |
600 | 590 |
|
601 | 591 |
|
602 | 592 | @composite |
@@ -826,6 +816,7 @@ def _write_fields_and_records_to_strict(w, fields, records): |
826 | 816 |
|
827 | 817 | @pytest.mark.hypothesis |
828 | 818 | @pytest.mark.hypothesis_dbf |
| 819 | +@reproduce_failure('6.155.7', b'AXicc2RgdGRoNHAEktRjsAAZHI4MDIwNMODI6MR+ASjJyAAAO+YVSQ==') |
829 | 820 | @settings(suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large]) |
830 | 821 | @given(codec_fields_and_records=dbf_encoding_fields_and_records()) |
831 | 822 | def test_dbf_reader_writer_roundtrip(codec_fields_and_records)-> None: |
|
0 commit comments