Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved coverage #103

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions .github/workflows/build_secondary_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand All @@ -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:
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ test/core.*
.idea/
.vs/
.coverage
coverage/
2 changes: 1 addition & 1 deletion mytest.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python test/debug.py && pytest
python test/debug.py && python -X faulthandler -m pytest -p no:faulthandler
2 changes: 1 addition & 1 deletion mytest.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rm test/core.*

./test/debug.py && pytest
./test/debug.py && python -X faulthandler -m pytest -p no:faulthandler
8 changes: 8 additions & 0 deletions test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
25 changes: 22 additions & 3 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
44 changes: 44 additions & 0 deletions test/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading