Skip to content

Commit

Permalink
fix warnings capture in crypto test
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Mar 4, 2024
1 parent fb29bef commit 0e975b9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/py/test_crypto.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import warnings

import pytest

Expand Down Expand Up @@ -57,13 +58,13 @@ def test_key_rotation(self):
assert new_info_2.payload == new_info.payload

def test_encrypt_dict_warns_of_single_key(self):
with pytest.warns(CryptoWarning, match="dict only contains one key") as warnings:
with pytest.warns(CryptoWarning, match="dict only contains one key") as w:
self.website.cryptograph.encrypt_dict({"long_single_key": None})
assert len(warnings) == 1
with pytest.warns(None) as warnings:
assert len(w) == 1
with warnings.catch_warnings(record=True) as w:
self.website.cryptograph.encrypt_dict({})
self.website.cryptograph.encrypt_dict({0: 1, 2: 3, 4: 5})
assert len(warnings) == 0
assert len(w) == 0

def test_encrypt_dict_randomizes_order(self):
cryptograph = self.website.cryptograph
Expand Down

0 comments on commit 0e975b9

Please sign in to comment.