Hi Noel,

sio.seek(0) before assert or sio.getvalue() instead read().

----
Pozdrawiam,  |  Best regards,
Maciek Wójcikowski
mac...@wojcikowski.pl

2017-09-08 15:51 GMT+02:00 Noel O'Boyle <baoille...@gmail.com>:

> Hi all,
>
> I'd like to capture error messages during SMILES parsing, but am having
> trouble getting this to work.
>
> The following code raises an AssertionError, for example. Is there
> something here I'm missing? I'm using this from a Windows 7 conda
> environment, Python 2.7 64-bit, RDKit 2017.03.3, but a similar conda
> environment is also failing for me on Linux.
>
> import sys
> from rdkit import Chem
> Chem.WrapLogs()
> from StringIO import StringIO
>
> old_stderr = sys.stderr
> sio = sys.stderr = StringIO()
>
> mol = Chem.MolFromSmiles("c1ccccc")
> sys.stderr = old_stderr
>
> assert sio.read() != ""
>
> Regards,
> - Noel
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to