diff --git a/.github/workflows/build_secondary_wheels.yml b/.github/workflows/build_secondary_wheels.yml index 54caba2..f574f2a 100644 --- a/.github/workflows/build_secondary_wheels.yml +++ b/.github/workflows/build_secondary_wheels.yml @@ -62,6 +62,12 @@ jobs: - name: Copy sdist package run: cp dist/frozendict-*.tar.gz dist/frozendict.tar.gz + + - name: Prepare system for core dumps + run: | + sudo mkdir /cores && + sudo chmod 777 /cores && + sudo bash -c 'echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern' - name: Build wheels uses: pypa/cibuildwheel@v2.16.5 @@ -72,6 +78,7 @@ jobs: CIBW_SKIP: "*-musllinux_*" CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: > + ulimit -c unlimited && python -X faulthandler {package}/test/debug.py && python -X faulthandler -m pytest -p no:faulthandler -s {package} with: @@ -84,3 +91,10 @@ jobs: uses: actions/upload-artifact@v3 with: path: dist/*.tar.gz + + - name: Upload core files + uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: cores + path: /cores diff --git a/.gitignore b/.gitignore index c07b4cc..2b5aa86 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ test/core.* .idea/ .vs/ .coverage +coverage/ diff --git a/mytest.bat b/mytest.bat index 944f844..ca2e70a 100644 --- a/mytest.bat +++ b/mytest.bat @@ -1 +1 @@ -python test/debug.py && pytest +python test/debug.py && python -X faulthandler -m pytest -p no:faulthandler diff --git a/mytest.sh b/mytest.sh index 6887c4e..2339920 100755 --- a/mytest.sh +++ b/mytest.sh @@ -1,3 +1,3 @@ rm test/core.* -./test/debug.py && pytest +./test/debug.py && python -X faulthandler -m pytest -p no:faulthandler diff --git a/test/base.py b/test/base.py index 512ff6f..de7a709 100644 --- a/test/base.py +++ b/test/base.py @@ -84,6 +84,10 @@ def fd_dict_2(self): def fd_dict_sabina(self): return {'Corrado': 'Guzzanti', 'Sabina': 'Guzzanti'} + @pytest.fixture + def fd_dict_none(self): + return {'Corrado': None, 'Sabina': None} + @pytest.fixture def generator_seq2(self, fd_dict): seq2 = list(fd_dict.items()) @@ -117,6 +121,10 @@ def fd2(self, fd_dict_2): def fd_sabina(self, fd_dict_sabina): return self.FrozendictClass(fd_dict_sabina) + @pytest.fixture + def fromkeys_keys(self): + return ["Corrado", "Sabina"] + @pytest.fixture def fd_items(self, fd_dict): return tuple(fd_dict.items()) diff --git a/test/common.py b/test/common.py index 9fbacb3..05ef129 100644 --- a/test/common.py +++ b/test/common.py @@ -129,6 +129,14 @@ def test_todict(self, fd, fd_dict): def test_get(self, fd): assert fd.get("Guzzanti") == "Corrado" + def test_get_bad(self, fd): + with pytest.raises(TypeError): + fd.get() + + def test_get_bad_2(self, fd): + with pytest.raises(TypeError): + fd.get(1, 2, 3) + def test_get_fail(self, fd): default = object() assert fd.get("Brignano", default) is default @@ -142,11 +150,22 @@ def test_values(self, fd, fd_dict): def test_items(self, fd, fd_dict): assert tuple(fd.items()) == tuple(fd_dict.items()) - def test_fromkeys(self, fd_sabina): - keys = ["Corrado", "Sabina"] - f = self.FrozendictClass.fromkeys(keys, "Guzzanti") + def test_fromkeys(self, fd_sabina, fromkeys_keys): + f = self.FrozendictClass.fromkeys(fromkeys_keys, "Guzzanti") assert f == fd_sabina + def test_fromkeys_bad(self): + with pytest.raises(TypeError): + f = self.FrozendictClass.fromkeys() + + def test_fromkeys_bad_2(self): + with pytest.raises(TypeError): + f = self.FrozendictClass.fromkeys(1, 2, 3) + + def test_fromkeys_default(self, fd_dict_none, fromkeys_keys): + f = self.FrozendictClass.fromkeys(fromkeys_keys) + assert f == fd_dict_none + def test_fromkeys_dict(self, fd_sabina, fd_dict_sabina): f = self.FrozendictClass.fromkeys(fd_dict_sabina, "Guzzanti") assert f == fd_sabina diff --git a/test/debug.py b/test/debug.py index a686379..d5b10df 100755 --- a/test/debug.py +++ b/test/debug.py @@ -1052,6 +1052,50 @@ def func_110(): functions.append(func_110) +@trace() +def func_111(): + try: + fd_1.get() + except TypeError: + pass + + +functions.append(func_111) + + +@trace() +def func_112(): + try: + fd_1.get(1, 2, 3) + except TypeError: + pass + + +functions.append(func_112) + + +@trace() +def func_113(): + try: + frozendict.fromkeys() + except TypeError: + pass + + +functions.append(func_113) + + +@trace() +def func_114(): + try: + frozendict.fromkeys(1, 2, 3) + except TypeError: + pass + + +functions.append(func_114) + + print_sep() for frozendict_class in (frozendict, F):