Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@parameterized.expand(
itertools.product(nums_controls, clean_ancilla_modes)
)
def test_mct_with_clean_ancillae(self, num_controls, mode):
c = QuantumRegister(num_controls, name='c')
o = QuantumRegister(1, name='o')
qc = QuantumCircuit(o, c)
num_ancillae = 0 if num_controls <= 2 else num_controls - 2
if num_ancillae > 0:
a = QuantumRegister(num_ancillae, name='a')
qc.add_register(a)
qc.h(c)
qc.mct(
[c[i] for i in range(num_controls)],
o[0],
[a[i] for i in range(num_ancillae)],
mode=mode
@parameterized.expand([
("cryptography"),
("secp256k1"),
("ecdsa")
])
def test_sign_message(self, module):
if module == "cryptography":
if not ecda.CRYPTOGRAPHY_AVAILABLE:
return
ecda.SECP256K1_MODULE = "cryptography"
elif module == "secp256k1":
if not ecda.SECP256K1_AVAILABLE:
return
ecda.SECP256K1_MODULE = "secp256k1"
else:
ecda.SECP256K1_MODULE = module
pub_key = py23_bytes(repr(PrivateKey(wif).pubkey), "latin")
@parameterized.expand([(cls.__name__, cls) for cls in BQM_SUBCLASSES])
def test_spin(self, name, BQM):
if not BQM.shapeable():
return
bqm = BQM({'a': 2, 'b': -8}, {('a', 'b'): -2, ('b', 'c'): 1}, 1.2,
dimod.SPIN)
bqm.contract_variables('a', 'b')
assert_consistent_bqm(bqm)
target = BQM({'a': -6}, {'ac': 1}, -.8, dimod.SPIN)
self.assertEqual(bqm, target)
@parameterized.expand(INSTALLERS)
def test_inexact_requirements(self, unused_test_name, packager_cls):
with self.plugin_resolution(plugins=[('jake', '1.2.3'), 'jane'],
packager_cls=packager_cls) as results:
working_set, chroot, repo_dir, cache_dir = results
self.assertEqual(2, len(working_set.entries))
# Kill the cache and the repo source dir and wait past our 1s test TTL, if the PluginResolver
# truly detects inexact plugin requirements it should skip perma-caching and fall through to
# pex to a TLL expiry resolve and then fail.
safe_rmtree(repo_dir)
safe_rmtree(cache_dir)
Crawler.reset_cache()
time.sleep(1.5)
with self.assertRaises(Unsatisfiable):
@parameterized.expand([
("default mount point", DEFAULT_MOUNT_POINT),
("custom mount point", 'other-ldap-tree'),
])
@requests_mock.Mocker()
def test_configure(self, test_label, mount_point, requests_mocker):
expected_status_code = 204
mock_url = 'http://localhost:8200/v1/auth/{mount_point}/config'.format(
mount_point=mount_point,
)
requests_mocker.register_uri(
method='POST',
url=mock_url,
status_code=expected_status_code,
)
ldap = Ldap(adapter=Request())
response = ldap.configure(
@parameterized(CIPHERTEXT_BLOB_VECTORS)
def test_cycle_ciphertext_blob(raw, _serialized):
test_serialized = _serialize_ciphertext_blob(raw)
test_deserialized = _deserialize_ciphertext_blob(test_serialized)
test_deserialized.should.equal(raw)
panda_jungle.set_panda_power(True)
time.sleep(5)
for serial in Panda.list():
p = Panda(serial=serial)
_panda_serials.append((serial, p.get_type()))
p.close()
print('Found', str(len(_panda_serials)), 'pandas')
init_panda_serials()
# Panda providers
test_all_types = parameterized([
param(panda_type=Panda.HW_TYPE_WHITE_PANDA),
param(panda_type=Panda.HW_TYPE_GREY_PANDA),
param(panda_type=Panda.HW_TYPE_BLACK_PANDA)
])
test_all_pandas = parameterized(
list(map(lambda x: x[0], _panda_serials))
)
test_all_gen2_pandas = parameterized(
list(map(lambda x: x[0], filter(lambda x: x[1] in GEN2_HW_TYPES, _panda_serials)))
)
test_white_and_grey = parameterized([
param(panda_type=Panda.HW_TYPE_WHITE_PANDA),
param(panda_type=Panda.HW_TYPE_GREY_PANDA)
])
test_white = parameterized([
param(panda_type=Panda.HW_TYPE_WHITE_PANDA)
])
test_grey = parameterized([
param(panda_type=Panda.HW_TYPE_GREY_PANDA)
])
test_black = parameterized([
@parameterized.expand([
param("Mimetype is not in binary types", ['image/gif'], "application/octet-stream")
])
def test_should_base64_encode_returns_false(self, test_case_name, binary_types, mimetype):
self.assertFalse(LocalApigwService._should_base64_encode(binary_types, mimetype))
@parameterized.expand(list(CONVERT_RGB.keys()))
def test_hist_matching(self, clr_space):
""" test run in parallel with failing experiment """
img = image_histogram_matching(self.img_src, self.img_ref, use_color=clr_space)
self.assertAlmostEqual(self.img_src.shape, img.shape)
@parameterized.expand([
['org.mpris.MediaPlayer2'],
['org.mpris.MediaPlayer2.Player'],
['org.freedesktop.DBus.Properties']
])
def test_constructs_dbus_interfaces(self, BusConnection, interface):
with patch('dbus.Interface') as Interface:
BusConnection.return_value = self.bus
self.create_example_dbus_connection()
Interface.assert_any_call(self.proxy, interface)