def test_missing_file_argument(): with pytest.raises(ValueError): aestar.AESFile(passphrase=b'12345678901234567890')
def test_both_file_and_fileobj(tmp_path): with pytest.raises(ValueError): with open(tmp_path / 'aesfile2.tmp', 'wb') as f: aestar.AESFile(passphrase=b'12345678901234567890', file=tmp_path / 'aesfile.tmp', fileobj=f)
def test_short_password_warning(short_passphrase, tmp_path): with pytest.warns(Warning): aesfile = aestar.AESFile(short_passphrase, file=tmp_path / 'aesfile.tmp')
def test_fileobj(passphrase, tmp_path): with open(tmp_path / 'aesfile_obj.tmp', 'wb') as f: aesfile = aestar.AESFile(passphrase, fileobj=f) aesfile.write(b'123') aesfile.close()
def aesfile(passphrase, tmp_path): return aestar.AESFile(passphrase=passphrase, file=tmp_path / 'aesfile.tmp')