I have an encryption project in python and i want to write an end to end test for whole project.
I can run the project in the command line, like this:
python -m serve -c config.json
for an end to end test, I wrote this test function, but when I ran it, an error occurs while everything in a simple run of the project from the command line is fine.
def test_assert_end_to_end(self):
args = []
config = load_config(args, "config.json")
t = threading.Thread(target=serve.run, name='serve', args=(args, ))
t = threading.Thread(target=serve.run, name='serve', args=(config,))
t.daemon = True
t.start()
self.unseal()
plain_data = bytes(''.join([chr(random.randint(0, 128))
for i in range(EndToEndTest.SIZE_OF_DATA_TO_ENCRYPT * 1024 * 1024)]), "utf-8")
EncryptResponseBytes = self.encrypt(plain_data)
DecryptResponseBytes = self.decrypt(EncryptResponseBytes)
self.assertEqual(plain_data, DecryptResponseBytes)
this is error's log:
signal.signal(signal.SIGTERM, self._graceful_exit)
File "/usr/lib/python3.6/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main threa
Anyone has any idea, how can I fix this error?
Aucun commentaire:
Enregistrer un commentaire