I've written a TLS parser library in C++ which now I need to write unit tests for. The library is simply fed the TLS data stream and it invokes various callbacks on certain events in TLS protocol. I'm searching for a Python implementation of TLS protocol for both client and server sides which allow me to create several deterministic and reproducible TLS data connections with parameters of my choosing (cipher suites, certificates, transmitting different TLS protocol messages, etc) and simultaneously dump the traffic in a raw binary file.
Does twisted allow me to create such test setup and if so is there any code sample available to help me jump start this project?
Ultimately Twisted will just speak TLS to a Transport and dump bytes into it; you can specify a pyOpenSSL context object configured however you like.  So this is really more of a question about pyOpenSSL or Cryptography.
The TLS handshake generally involves generating random data (session keys) at various points.  While I think it is probably possible to make OpenSSL do something completely deterministic by plugging in a special ENGINE that generates non-random random data, this is a use-case that the Twisted TLS toolchain is definitely not geared towards.  (For example, randomness is always global in OpenSSL, even though the other parts of the SSL stack are local to the SSL_CTX.)
Create a controlled TLS conversation in Python twisted and store it to be used as test data