Understanding points of entry

52 views
Skip to first unread message

Andrew Berger

unread,
Jun 23, 2015, 5:17:58 PM6/23/15
to pytho...@googlegroups.com
Hey all  - I was amazed to discover this library when I haphazardly googled 'python auto unittest generation'. I'm having a grand old time playing around with it. 

One thing that hasn't been clear and I haven't really been able to discern from the docs is what exactly the effect creating a point of entry will have. This seems like an extremely powerful feature and it should be advertised as such!  It would be nice to know (at a high level) what pythoscope discerns from a point of entry and how, and what the effects might be if I set a little snippet of actual usage code as a point of entry instead of just an import and initialization. 

Cheers, 
Andrew

Michał Kwiatkowski

unread,
Jun 24, 2015, 7:33:45 AM6/24/15
to pytho...@googlegroups.com
Hi Andrew, thanks for trying out Pythoscope!

Points of entry are a way for the programmer to specify code that's safe to run. In principle, Pythoscope could try to run project's code at random, but there's always a possibility some snippet is an equivalent of "rm -rf /" or "DROP DATABASE" or similar. That's why we have points of entry.

You run your project and call whatever functions you want. If that's a web app you can click through pages, submit forms, etc. As the app is running, Pythoscope is gathering information on objects created, functions called, etc. Based on that it can generate real test cases, including the setup and teardown code. Whatever information was gathered during the POE run will become the base for test generation. This includes things like user input, file contents, function arguments, etc.

Let me know if that answers your question.

Cheers,
mk

--
You received this message because you are subscribed to the Google Groups "Pythoscope" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythoscope+...@googlegroups.com.
To post to this group, send email to pytho...@googlegroups.com.
Visit this group at http://groups.google.com/group/pythoscope.
For more options, visit https://groups.google.com/d/optout.

Matt Wilkie

unread,
Jun 26, 2015, 5:44:43 PM6/26/15
to pytho...@googlegroups.com
On Wed, Jun 24, 2015 at 4:33 AM, Michał Kwiatkowski <mic...@trivas.pl> wrote:
Points of entry are a way for the programmer to specify code that's safe to run. ...

Nice succinct and quickly understandable explanation. It cleared up a lot of confusion for me, thank you!

Matt

Thomas Zheng

unread,
Jul 29, 2015, 12:28:53 PM7/29/15
to Pythoscope, mic...@trivas.pl
I dont quite follow this part of the explanation.

"You run your project and call whatever functions you want. If that's a web app you can click through pages, submit forms, etc. As the app is running, Pythoscope is gathering information on objects created, functions called, etc. Based on that it can generate real test cases, including the setup and teardown code. Whatever information was gathered during the POE run will become the base for test generation. This includes things like user input, file contents, function arguments, etc."

Using the old_python example from the documentation, i create a POE, 
# .pythoscope/points-of-entry/old_nest_with_four_pythons.py
from old_nest import OldNest
OldNest([45, 55, 65, 75]).put_hand()

Are you saying pythoscope will run old_nest_with_four_pythons.py , which could be a large and complicated app, and it will generate test cases as the app is being run?  

If that's true, that means old_nest_with_four_pythons.py  can contain a lot more code than is shown. right?  What kind of criteria does pythoscope use to determine what new and dynamic test cases to generate?

Thanks in advance!

Michał Kwiatkowski

unread,
Jul 30, 2015, 5:22:40 AM7/30/15
to Thomas Zheng, Pythoscope
śr., 29.07.2015 o 03:22 użytkownik Thomas Zheng <thomas....@gmail.com> napisał:
Using the old_python example from the documentation, i create a POE, 
# .pythoscope/points-of-entry/old_nest_with_four_pythons.py
from old_nest import OldNest
OldNest([45, 55, 65, 75]).put_hand()
Are you saying pythoscope will run old_nest_with_four_pythons.py , which could be a large and complicated app, and it will generate test cases as the app is being run?  

If that's true, that means old_nest_with_four_pythons.py  can contain a lot more code than is shown. right?  What kind of criteria does pythoscope use to determine what new and dynamic test cases to generate?

Yes, all code in the point of entry will be run and this will be the basis for the generated tests. All object creations and function/method calls will get traced and then test cases will get generated based on that. For dynamic test generation it's not so much about what code you physically have in a POE file, but what code is being run as triggered by the POE.

I don't remember exactly, but currently I think Pythoscope generates one test case for each function/method call it captures.

The idea of POE is not so much to contain code, but to provide... well, a point to enter into the app's code. You could put a single import and a call main() there and that would suffice. Interactive apps are easiest to test this way, because you can start it up and generate test cases by simply using the app.

Note that Pythoscope is not a finished tool, and while the principles I described are implemented, there are a lot of small details and corner cases that still need to be handled.

I hope that helps you undestand POE and Pythoscope.

Cheers,
mk

Marc Brooks

unread,
Oct 23, 2015, 6:08:04 AM10/23/15
to Pythoscope, thomas....@gmail.com, mic...@trivas.pl

Can you talk a bit more about how could do that with interactive apps?  I have a Python Flask app, and I'd love to fire it up and generate test cases by using the app.

Thanks,
Marc

Michał Kwiatkowski

unread,
Oct 25, 2015, 6:38:09 AM10/25/15
to Marc Brooks, Pythoscope, thomas....@gmail.com
Sure. Based on the quickstart docs ( http://flask.pocoo.org/docs/0.10/quickstart/ ) you can run a flask app by doing "app.run()" given that "app" is a Flask application object.

Create a file in the .pythoscope/points-of-entry/ directory, import your app and call "run()" on it. Run pythoscope and it will run the point of entry automatically. Interact with the application in the browser for a while and then stop the server (not sure about this step, Ctrl+c on pythoscope might work). Pythoscope should generate some real test cases for you.

I hope this will help you get started. Let me know how it went.

Cheers,
mk
Reply all
Reply to author
Forward
0 new messages