<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body dir="auto" style="word-wrap:break-word" fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Rob
<div><br>
</div>
<div>Yes, I have that impression about unittest, but could not locate documentation which teaches me how to use it to test my code.</div>
<div><br>
</div>
<div>The system I want to test is a discrete event simulator. Its primary components are a simulation engine and a set of simulation objects which represent the components of the system being modeled.&nbsp;</div>
<div>The initialization of a simulation program creates the simulation objects, each of which registers with the engine. Initialization must also create at least one event. Events are stored in the engine. The simulation is started by executing the engine’s
 scheduler method.&nbsp;</div>
<div>The scheduler repeatedly chooses the next event and calls the event handler in the simulation object that receives the event. The event handler can schedule future events for any simulation object, including itself. The simulation ends when it runs out
 of events to process, exceeds a termination time, or fails.&nbsp;</div>
<div>My tests use some real simulation objects and&nbsp;some&nbsp;test simulation objects. They exchange events with each other. I want the test objects to verify assertions about the state of the events they receive from the real simulation objects.&nbsp;</div>
<div><br>
</div>
<div>I can show you code if that would help.</div>
<div><br>
</div>
<div>Thanks very much</div>
<div>Arthur</div>
<div><br>
<div class="AppleOriginalContents" style="direction:ltr">
<div>On Jun 22, 2016, at 11:32 PM, Robert Collins &lt;robertc@robertcollins.net&gt; wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">unittest doesn't care about inheritance much (the loader cares, but<br>
nothing else) - but I don't understand when you say 'must be<br>
written... in class X'.<br>
<br>
Can you give some more detail about why that is ? E.g. its a GUI<br>
framework and you want to have your assertion take place in response<br>
to a GUI event?<br>
<br>
-Rob<br>
<br>
On 23 June 2016 at 15:24, Goldberg, Arthur P &lt;arthur.p.goldberg@mssm.edu&gt; wrote:<br>
<blockquote type="cite">Hello<br>
<br>
I’ve extensive experience using Python unittest. However, I’ve some new code<br>
that I cannot test with unittest because the assertions must be applied in a<br>
derived class (call it class X) that contains methods executed by an<br>
application layer scheduler. Thus, tests of this code cannot be written as<br>
methods named test*() in a class derived from unittest.TestCase.<br>
<br>
I attempted to address this problem by using pytest, because it is easy to<br>
write assert statements in class X. However, pytest doesn’t find the assert<br>
statements. Rather it reports “collected 0 items”.<br>
<br>
Investigating further, I ran pytest —debug. In a cryptic, 700&#43; line log file<br>
it reports “message: cannot collect test class 'TestSimulationObject'<br>
because it has a __init__ constructor”. This doesn’t make sense. Python<br>
classes almost always use an __init__ constructor. Nevertheless, I tried<br>
removing the class X’s __init__() constructor and initializing its<br>
attributes through another method. But pytest —debug still reports the same<br>
message in the debug log.<br>
<br>
My primary interest is to automate the testing of class X. It would be nice<br>
if that could be done with Python unittest by making direct calls to the<br>
TestCase API but I suspect that would require more effort than I want to<br>
devote to solving this problem. Probably the best approach would be to use<br>
another testing framework that offers similar flexibility to pytest, but<br>
does indeed test Class X.<br>
<br>
Please let me know what you think or recommend.<br>
Thanks<br>
Arthur<br>
<br>
---<br>
<br>
Arthur Goldberg, PhD<br>
Associate Professor of Genetics and Genomic Sciences<br>
Icahn Institute for Genomics &amp; Multiscale Biology<br>
Icahn School of Medicine at Mount Sinai<br>
646 526 5020<br>
Karr Lab<br>
Arthur.Goldberg@mssm.edu<br>
Follow us on Twitter @IcahnInstitute<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
testing-in-python mailing list<br>
testing-in-python@lists.idyll.org<br>
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.idyll.org_listinfo_testing-2Din-2Dpython&amp;d=AwIFaQ&amp;c=4R1YgkJNMyVWjMjneTwN5tJRn8m8VqTSNCjYLg1wNX4&amp;r=TntoeYH7lekXzpBRjXwLTkqiWTbWAvp3pHKo_kZp5qI&amp;m=YJ-P8A_IxL3Zjky1E-3bFdXBuYKHfErI7GLYVgHRY7I&amp;s=05Ldl4firRTVfeTf5Ad0_M_ahV0oFO7ITHW5_DXvIEc&amp;e=
<br>
<br>
</blockquote>
</blockquote>
</div>
<br>
<div id="AppleMailSignature">
<div style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div>
<div style="orphans:2; widows:2; border-collapse:separate; border-spacing:0px">
<div style="border-collapse:separate; border-spacing:0px">---</div>
<div>&nbsp;</div>
<div>Arthur Goldberg, PhD
<div style="border-collapse:separate; border-spacing:0px">Associate Professor of Genetics and Genomic Sciences</div>
<div style="border-collapse:separate; border-spacing:0px">Icahn Institute for Genomics &amp;&nbsp;Multiscale Biology</div>
<div>Icahn School of Medicine at Mount Sinai</div>
<div>
<div style="border-collapse:separate; border-spacing:0px">646 526 5020</div>
</div>
<div style="border-collapse:separate; border-spacing:0px"><a href="http://www.karrlab.org/" target="_blank">Karr Lab</a></div>
<div style="border-collapse:separate; border-spacing:0px"><a href="mailto:Arthur.Goldberg@mssm.edu" target="_blank">Arthur.Goldberg@mssm.edu</a></div>
</div>
</div>
<div style="orphans:2; widows:2">Follow us on Twitter&nbsp;<a href="https://twitter.com/IcahnInstitute" target="_blank">@IcahnInstitute</a></div>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br class="Apple-interchange-newline">
<br class="Apple-interchange-newline">
</div>
<br>
</div>
</div>
</body>
</html>