From py-svn at codespeak.net Sat Nov 1 08:07:58 2008 From: py-svn at codespeak.net (VIAGRA INC) Date: Sat, 1 Nov 2008 08:07:58 +0100 (CET) Subject: [py-svn] SALE 89% OFF Message-ID: <20081101-50613.28122.qmail@c3nat.acxiom.com> An HTML attachment was scrubbed... URL: From pedronis at codespeak.net Sat Nov 1 11:01:45 2008 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sat, 1 Nov 2008 11:01:45 +0100 (CET) Subject: [py-svn] r59615 - in py/trunk/py/test: . testing Message-ID: <20081101100145.5946B16A24B@codespeak.net> Author: pedronis Date: Sat Nov 1 11:01:44 2008 New Revision: 59615 Modified: py/trunk/py/test/resultlog.py py/trunk/py/test/session.py py/trunk/py/test/testing/test_config.py Log: given the format and the fact that external timeout logic may kill a py.test emitting a resultlog switching to line buffering seems a good idea Modified: py/trunk/py/test/resultlog.py ============================================================================== --- py/trunk/py/test/resultlog.py (original) +++ py/trunk/py/test/resultlog.py Sat Nov 1 11:01:44 2008 @@ -28,7 +28,7 @@ def __init__(self, bus, logfile): bus.subscribe(self.log_event_to_file) - self.logfile = logfile #open(logpath, 'w') # line buffering ? + self.logfile = logfile # preferably line buffered def write_log_entry(self, shortrepr, name, longrepr): print >>self.logfile, "%s %s" % (shortrepr, name) Modified: py/trunk/py/test/session.py ============================================================================== --- py/trunk/py/test/session.py (original) +++ py/trunk/py/test/session.py Sat Nov 1 11:01:44 2008 @@ -37,7 +37,7 @@ self.bus.subscribe(eventwrite) resultlog = self.config.option.resultlog if resultlog: - f = py.path.local(resultlog).open('w') + f = open(resultlog, 'w', 1) # line buffered self.resultlog = ResultLog(self.bus, f) def fixoptions(self): Modified: py/trunk/py/test/testing/test_config.py ============================================================================== --- py/trunk/py/test/testing/test_config.py (original) +++ py/trunk/py/test/testing/test_config.py Sat Nov 1 11:01:44 2008 @@ -196,8 +196,6 @@ rep_ev = event.ItemTestReport(item, passed=outcome) session.bus.notify(rep_ev) - - session.resultlog.logfile.flush() s = resultlog.read() assert s.find(". a") != -1 From hpk at codespeak.net Sun Nov 2 19:04:53 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Sun, 2 Nov 2008 19:04:53 +0100 (CET) Subject: [py-svn] r59664 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081102180453.529E716A016@codespeak.net> Author: hpk Date: Sun Nov 2 19:04:52 2008 New Revision: 59664 Added: py/extradoc/talk/pycon-us-2009/ py/extradoc/talk/pycon-us-2009/proposal-pytest.txt (contents, props changed) Log: first draft of proposal Added: py/extradoc/talk/pycon-us-2009/proposal-pytest.txt ============================================================================== --- (empty file) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Sun Nov 2 19:04:52 2008 @@ -0,0 +1,75 @@ +Title: py.test - rapid testing with minimal effort +Presenter: Holger Krekel +Tutorial format: interactive lecture +Recording: i give permission to record and publish my PyCon tutorial for free distribution. +Intended Audience: beginner programmers +Maximum number of students: maybe 30 +Perequisites/knowledge: basic knowledge of python programming +Requirements: Attendees are welcome to bring their laptops with Python installed (version 2.4 or higher). + +Presenter bio: + +Holger Krekel is a co-founder of the PyPy project and +participates on many levels in it. He is the initiator and +maintainer of the popular py.test and a few other tools. In +2004 he founded merlinux, a company organising itself +virtually, mostly with european developers from PyPy and +py.test contexts. Holger has presented on PyPy and py.test +on many EuroPython and PyCon confereces and has given well +received testing tutorials at EuroPython 2008 and Pycon-UK 2008. + +Tutorial Summary: + +XXX +This tutorial talk introduces usage of py.test, a popular tool +for writing and running automated tests. We walk through the +implementation of tests, layered setup of test state and how +to write project specific or global extensions. We discuss the +current feature set including extensions for generating HTML +pages, running tests for other languages such as Javascript +or for distributing tests across machines. + + +Outline for review: + +Terminology/Overview (15 minutes) +- developer and "customer" tests +- small/medium/big tests aka unit/functional/integration +- acceptance tests +- benefits of automated testing +- existing python testing tools + +Basic usage of py.test (45 minutes) +- installation +- test functions, test classes +- setup and teardown test state +- skipping tests +- generative tests +- doctests +- skipping chunks within doctests +- looponfailing: run large test set until all tests pass + +Using existing extensions (30 minutes) +- integrate collection/run of traditional unit-tests +- run functions in their own tempdir +- testing ReST documents +- running Javascript tests +- running Prolog tests +- html reporting for nightly runs + +Writing extensions (30 minutes) +- event system for reporting +- conftest.py mechanism +- test collection hooks +- test running hooks +- writing cross-project plugins + +Distributed testing (30 minutes) +- motivation/vision +- run your tests on multiple CPUs/multicore +- running tests on multiple machines at once +- running tests cross-platform +- do's and dont's for cross-process testing + +Buffer and Questions & Answers + From hpk at codespeak.net Mon Nov 3 03:26:51 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 3 Nov 2008 03:26:51 +0100 (CET) Subject: [py-svn] r59670 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103022651.14D2616A151@codespeak.net> Author: hpk Date: Mon Nov 3 03:26:49 2008 New Revision: 59670 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Log: rewriting summary, refining outline a bit. should be rather final Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Mon Nov 3 03:26:49 2008 @@ -12,22 +12,20 @@ Holger Krekel is a co-founder of the PyPy project and participates on many levels in it. He is the initiator and maintainer of the popular py.test and a few other tools. In -2004 he founded merlinux, a company organising itself -virtually, mostly with european developers from PyPy and -py.test contexts. Holger has presented on PyPy and py.test -on many EuroPython and PyCon confereces and has given well -received testing tutorials at EuroPython 2008 and Pycon-UK 2008. +2004 he founded merlinux, a company focusing on PyPy and py.test +developments. Holger has talks at many EuroPython and +PyCon confereces and gave well received testing +tutorials at EuroPython 2008 and Pycon-UK 2008. Tutorial Summary: -XXX -This tutorial talk introduces usage of py.test, a popular tool -for writing and running automated tests. We walk through the -implementation of tests, layered setup of test state and how -to write project specific or global extensions. We discuss the -current feature set including extensions for generating HTML -pages, running tests for other languages such as Javascript -or for distributing tests across machines. +This tutorial discusses basic and advanced features +of py.test, a popular testing tool. We walk through the +implementation of tests, layered setup of test state and debugging +facilities. We discuss the current feature set including using +and writing extensions for generating HTML pages, running Javascript +tests or testing RestructuredText documents. We also showcase and +discuss ways of distributing tests across CPUs and platforms. Outline for review: @@ -42,6 +40,8 @@ Basic usage of py.test (45 minutes) - installation - test functions, test classes +- working with failures +- reinterpretation of asserts - setup and teardown test state - skipping tests - generative tests @@ -58,7 +58,7 @@ - html reporting for nightly runs Writing extensions (30 minutes) -- event system for reporting +- event system for custom reporting - conftest.py mechanism - test collection hooks - test running hooks @@ -71,5 +71,5 @@ - running tests cross-platform - do's and dont's for cross-process testing -Buffer and Questions & Answers +Buffer, Q&A (30 minutes) From briandorsey at codespeak.net Mon Nov 3 07:34:16 2008 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 3 Nov 2008 07:34:16 +0100 (CET) Subject: [py-svn] r59673 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103063416.7F91416A003@codespeak.net> Author: briandorsey Date: Mon Nov 3 07:34:15 2008 New Revision: 59673 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Log: small rewording and added 'break' Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Mon Nov 3 07:34:15 2008 @@ -10,10 +10,10 @@ Presenter bio: Holger Krekel is a co-founder of the PyPy project and -participates on many levels in it. He is the initiator and +participates on many levels. He is the initiator and maintainer of the popular py.test and a few other tools. In 2004 he founded merlinux, a company focusing on PyPy and py.test -developments. Holger has talks at many EuroPython and +developments. Holger has spoken at many EuroPython and PyCon confereces and gave well received testing tutorials at EuroPython 2008 and Pycon-UK 2008. @@ -57,6 +57,8 @@ - running Prolog tests - html reporting for nightly runs +Break + Writing extensions (30 minutes) - event system for custom reporting - conftest.py mechanism From briandorsey at codespeak.net Mon Nov 3 07:42:46 2008 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 3 Nov 2008 07:42:46 +0100 (CET) Subject: [py-svn] r59674 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103064246.BB5F916A040@codespeak.net> Author: briandorsey Date: Mon Nov 3 07:42:44 2008 New Revision: 59674 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Log: Added sentance about the format of the tutorial, so people don't think it's a hands-on session. Also added a sentance about an open space session later... maybe that should be taken back out? Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Mon Nov 3 07:42:44 2008 @@ -25,7 +25,10 @@ facilities. We discuss the current feature set including using and writing extensions for generating HTML pages, running Javascript tests or testing RestructuredText documents. We also showcase and -discuss ways of distributing tests across CPUs and platforms. +discuss ways of distributing tests across CPUs and platforms. The +tutorial format will be an interactive lecture with plenty of time +for questions. We plan to host separate Open Space time later in +the conference for hands on experimentation. Outline for review: From hpk at codespeak.net Mon Nov 3 19:38:05 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 3 Nov 2008 19:38:05 +0100 (CET) Subject: [py-svn] r59692 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103183805.DA185169FAA@codespeak.net> Author: hpk Date: Mon Nov 3 19:38:01 2008 New Revision: 59692 Added: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt - copied, changed from r59691, py/extradoc/talk/pycon-us-2009/proposal-pytest.txt py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt - copied, changed from r59691, py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Removed: py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Log: splitting proposal into two Copied: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt (from r59691, py/extradoc/talk/pycon-us-2009/proposal-pytest.txt) ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt Mon Nov 3 19:38:01 2008 @@ -1,10 +1,10 @@ -Title: py.test - rapid testing with minimal effort -Presenter: Holger Krekel +Title: py.test - cross-platform and distributed testing +Presenter: Holger Krekel , Brian Tutorial format: interactive lecture Recording: i give permission to record and publish my PyCon tutorial for free distribution. -Intended Audience: beginner programmers +Intended Audience: Python programmers Maximum number of students: maybe 30 -Perequisites/knowledge: basic knowledge of python programming +Perequisites/knowledge: good knowledge of python programming, basic familiarity with automated testing Requirements: Attendees are welcome to bring their laptops with Python installed (version 2.4 or higher). Presenter bio: @@ -17,42 +17,44 @@ PyCon confereces and gave well received testing tutorials at EuroPython 2008 and Pycon-UK 2008. -Tutorial Summary: +XXX Brian -This tutorial discusses basic and advanced features -of py.test, a popular testing tool. We walk through the -implementation of tests, layered setup of test state and debugging -facilities. We discuss the current feature set including using -and writing extensions for generating HTML pages, running Javascript -tests or testing RestructuredText documents. We also showcase and -discuss ways of distributing tests across CPUs and platforms. The -tutorial format will be an interactive lecture with plenty of time -for questions. We plan to host separate Open Space time later in -the conference for hands on experimentation. +Tutorial Summary: +Interested to deepen your understanding of automated testing with Python? +To use a tool that allows to ad-hoc distribute tests to multiple +CPUs for speed and to multiple platforms for compatibility checks? +With tons of debugging help for failure situations? + +This tutorial provides in-depth information on advanced usages +of the popular py.test tool. We discuss its current feature set +including using and writing extensions for generating HTML pages, +testing Javascript or ReST documents. We showcase and discuss ways +of distributing tests across CPUs and platforms and will leave +time to discuss specific scenarios brought up during the session. + +The tutorial format will be an interactive lecture with plenty +of time for questions. We plan to host separate Open Space +time later in the conference for discussing things in a wider +audience. Outline for review: -Terminology/Overview (15 minutes) +Terminology/Overview (20 minutes) - developer and "customer" tests - small/medium/big tests aka unit/functional/integration - acceptance tests - benefits of automated testing - existing python testing tools -Basic usage of py.test (45 minutes) -- installation -- test functions, test classes -- working with failures -- reinterpretation of asserts -- setup and teardown test state -- skipping tests +Walkthrough py.test basic features (30 minutes) +- example of test module +- working with failures, tracebacks - generative tests -- doctests - skipping chunks within doctests - looponfailing: run large test set until all tests pass -Using existing extensions (30 minutes) +Using extensions (30 minutes) - integrate collection/run of traditional unit-tests - run functions in their own tempdir - testing ReST documents @@ -60,21 +62,24 @@ - running Prolog tests - html reporting for nightly runs -Break +Break (10 minutes) Writing extensions (30 minutes) -- event system for custom reporting +- overview on extensibility +- per-project hooks for customization - conftest.py mechanism +- global hooks for plugins +- event system for custom reporting - test collection hooks - test running hooks - writing cross-project plugins -Distributed testing (30 minutes) +Distributed testing (40 minutes) - motivation/vision - run your tests on multiple CPUs/multicore - running tests on multiple machines at once -- running tests cross-platform +- running tests on windows, driven by Unix - do's and dont's for cross-process testing -Buffer, Q&A (30 minutes) +Buffer, Q&A (20 minutes) Copied: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt (from r59691, py/extradoc/talk/pycon-us-2009/proposal-pytest.txt) ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Mon Nov 3 19:38:01 2008 @@ -1,14 +1,16 @@ Title: py.test - rapid testing with minimal effort -Presenter: Holger Krekel +Presenter: Brian Dorsey , Holger Krekel Tutorial format: interactive lecture Recording: i give permission to record and publish my PyCon tutorial for free distribution. Intended Audience: beginner programmers Maximum number of students: maybe 30 Perequisites/knowledge: basic knowledge of python programming -Requirements: Attendees are welcome to bring their laptops with Python installed (version 2.4 or higher). +Requirements: XXX Presenter bio: +Brian XXX + Holger Krekel is a co-founder of the PyPy project and participates on many levels. He is the initiator and maintainer of the popular py.test and a few other tools. In @@ -19,28 +21,25 @@ Tutorial Summary: -This tutorial discusses basic and advanced features -of py.test, a popular testing tool. We walk through the -implementation of tests, layered setup of test state and debugging -facilities. We discuss the current feature set including using -and writing extensions for generating HTML pages, running Javascript -tests or testing RestructuredText documents. We also showcase and -discuss ways of distributing tests across CPUs and platforms. The -tutorial format will be an interactive lecture with plenty of time -for questions. We plan to host separate Open Space time later in -the conference for hands on experimentation. +XXX modify and refine +This tutorial introduces to automated testing for Python +and discusses basic usage of py.test. +We walk through the implementation of tests, layered setup of test state and debugging +facilities and point out differences to other test tools. XXX +We discuss and walk through the current feature set including +using and writing extensions for running Javascript tests or +testing the format of text documents. Outline for review: -Terminology/Overview (15 minutes) -- developer and "customer" tests -- small/medium/big tests aka unit/functional/integration -- acceptance tests -- benefits of automated testing +Motivation / why automated testing? (15 minutes) +XXX - existing python testing tools +- similarities of nose and py.test Basic usage of py.test (45 minutes) +XXX extend, split intwo two sections? - installation - test functions, test classes - working with failures @@ -57,24 +56,6 @@ - run functions in their own tempdir - testing ReST documents - running Javascript tests -- running Prolog tests -- html reporting for nightly runs Break -Writing extensions (30 minutes) -- event system for custom reporting -- conftest.py mechanism -- test collection hooks -- test running hooks -- writing cross-project plugins - -Distributed testing (30 minutes) -- motivation/vision -- run your tests on multiple CPUs/multicore -- running tests on multiple machines at once -- running tests cross-platform -- do's and dont's for cross-process testing - -Buffer, Q&A (30 minutes) - Deleted: /py/extradoc/talk/pycon-us-2009/proposal-pytest.txt ============================================================================== --- /py/extradoc/talk/pycon-us-2009/proposal-pytest.txt Mon Nov 3 19:38:01 2008 +++ (empty file) @@ -1,80 +0,0 @@ -Title: py.test - rapid testing with minimal effort -Presenter: Holger Krekel -Tutorial format: interactive lecture -Recording: i give permission to record and publish my PyCon tutorial for free distribution. -Intended Audience: beginner programmers -Maximum number of students: maybe 30 -Perequisites/knowledge: basic knowledge of python programming -Requirements: Attendees are welcome to bring their laptops with Python installed (version 2.4 or higher). - -Presenter bio: - -Holger Krekel is a co-founder of the PyPy project and -participates on many levels. He is the initiator and -maintainer of the popular py.test and a few other tools. In -2004 he founded merlinux, a company focusing on PyPy and py.test -developments. Holger has spoken at many EuroPython and -PyCon confereces and gave well received testing -tutorials at EuroPython 2008 and Pycon-UK 2008. - -Tutorial Summary: - -This tutorial discusses basic and advanced features -of py.test, a popular testing tool. We walk through the -implementation of tests, layered setup of test state and debugging -facilities. We discuss the current feature set including using -and writing extensions for generating HTML pages, running Javascript -tests or testing RestructuredText documents. We also showcase and -discuss ways of distributing tests across CPUs and platforms. The -tutorial format will be an interactive lecture with plenty of time -for questions. We plan to host separate Open Space time later in -the conference for hands on experimentation. - - -Outline for review: - -Terminology/Overview (15 minutes) -- developer and "customer" tests -- small/medium/big tests aka unit/functional/integration -- acceptance tests -- benefits of automated testing -- existing python testing tools - -Basic usage of py.test (45 minutes) -- installation -- test functions, test classes -- working with failures -- reinterpretation of asserts -- setup and teardown test state -- skipping tests -- generative tests -- doctests -- skipping chunks within doctests -- looponfailing: run large test set until all tests pass - -Using existing extensions (30 minutes) -- integrate collection/run of traditional unit-tests -- run functions in their own tempdir -- testing ReST documents -- running Javascript tests -- running Prolog tests -- html reporting for nightly runs - -Break - -Writing extensions (30 minutes) -- event system for custom reporting -- conftest.py mechanism -- test collection hooks -- test running hooks -- writing cross-project plugins - -Distributed testing (30 minutes) -- motivation/vision -- run your tests on multiple CPUs/multicore -- running tests on multiple machines at once -- running tests cross-platform -- do's and dont's for cross-process testing - -Buffer, Q&A (30 minutes) - From hpk at codespeak.net Mon Nov 3 19:43:13 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 3 Nov 2008 19:43:13 +0100 (CET) Subject: [py-svn] r59693 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103184313.39EB9169FBB@codespeak.net> Author: hpk Date: Mon Nov 3 19:43:12 2008 New Revision: 59693 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt Log: recommend to visit other tutorial Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt Mon Nov 3 19:43:12 2008 @@ -6,6 +6,7 @@ Maximum number of students: maybe 30 Perequisites/knowledge: good knowledge of python programming, basic familiarity with automated testing Requirements: Attendees are welcome to bring their laptops with Python installed (version 2.4 or higher). +Notes to reviewer: visting the beginner-oriented tutorial "rapid testing with minimal effort" is recommended, but not required. Presenter bio: From briandorsey at codespeak.net Mon Nov 3 21:09:12 2008 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 3 Nov 2008 21:09:12 +0100 (CET) Subject: [py-svn] r59697 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103200912.8BC73169F97@codespeak.net> Author: briandorsey Date: Mon Nov 3 21:09:08 2008 New Revision: 59697 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Log: Begining to flesh out beginning outline. Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Mon Nov 3 21:09:08 2008 @@ -1,15 +1,22 @@ Title: py.test - rapid testing with minimal effort -Presenter: Brian Dorsey , Holger Krekel +Presenter: Brian Dorsey , Holger Krekel Tutorial format: interactive lecture -Recording: i give permission to record and publish my PyCon tutorial for free distribution. +Recording: I give permission to record and publish my PyCon tutorial for free distribution. Intended Audience: beginner programmers Maximum number of students: maybe 30 Perequisites/knowledge: basic knowledge of python programming -Requirements: XXX +Requirements: Laptop with Python 2.4 or greater installed. Or pair with someone. :) Presenter bio: -Brian XXX +Brian Dorsey is a database and Python developer living in Seattle Washington, +USA. He mostly writes command line tools, windows services and more recntly +simple web apps. He is a long-time user of and occasional contributor to +py.test. He is a co-organizer of the Seattle Python Interest Group +(www.seapig.org), a member of www.saturdayhouse.org and co-founder of a +co-working space in Seattle (www.giraffelabs.com). He also loves lunch and +created www.noonhat.com to help feed that addiction. He doesn't like natto or +talking about himself in the third person. Holger Krekel is a co-founder of the PyPy project and participates on many levels. He is the initiator and @@ -35,15 +42,21 @@ Motivation / why automated testing? (15 minutes) XXX +- what is unit testing and how does it compare to other types of testing +- why do unit testing? benefits, etc - existing python testing tools -- similarities of nose and py.test +- similarities and differences between nose and py.test -Basic usage of py.test (45 minutes) -XXX extend, split intwo two sections? +Installation, basic test functions. (30 minutes) - installation -- test functions, test classes +- test functions +- 20 minute work time (basic setup and working through inevitable setup problems) + +Basic usage of py.test (45 minutes) +XXX extend, split into two sections? - working with failures - reinterpretation of asserts +- test classes - setup and teardown test state - skipping tests - generative tests @@ -51,11 +64,18 @@ - skipping chunks within doctests - looponfailing: run large test set until all tests pass +Break + +XXX possible topics? +TDD? +Mock objects? +continuous integration (running as part of a build)? +coverage? + Using existing extensions (30 minutes) - integrate collection/run of traditional unit-tests - run functions in their own tempdir - testing ReST documents - running Javascript tests -Break From briandorsey at codespeak.net Mon Nov 3 21:50:38 2008 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 3 Nov 2008 21:50:38 +0100 (CET) Subject: [py-svn] r59698 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103205038.80988169E7B@codespeak.net> Author: briandorsey Date: Mon Nov 3 21:50:36 2008 New Revision: 59698 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Log: more outline updates Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Mon Nov 3 21:50:36 2008 @@ -40,42 +40,58 @@ Outline for review: -Motivation / why automated testing? (15 minutes) -XXX +Motivation / why automated testing? (10 minutes) - what is unit testing and how does it compare to other types of testing - why do unit testing? benefits, etc - existing python testing tools + +What you get with py.test (10 minutes) +- overview of all the basic benefits - automatic test discovery, simplicity, 'print' debugging (output redirection), function or class, assert introspection, etc +- extra benefits, there if you need them, ignore if not - multiple python version, distributed testing, doctests, etc, etc - similarities and differences between nose and py.test Installation, basic test functions. (30 minutes) - installation - test functions -- 20 minute work time (basic setup and working through inevitable setup problems) +- 20 minute work time + - Basic setup and working through inevitable setup problems. Some people will finish very quickly - ask them to help others get setup. -Basic usage of py.test (45 minutes) -XXX extend, split into two sections? -- working with failures +Basic usage of py.test (40 minutes) - reinterpretation of asserts +- working with failures - debug with print +- exceptions +- 10 minute work time - exercises - test classes - setup and teardown test state - skipping tests -- generative tests -- doctests -- skipping chunks within doctests -- looponfailing: run large test set until all tests pass +- 10 minute work time - exercises Break -XXX possible topics? -TDD? -Mock objects? -continuous integration (running as part of a build)? -coverage? +Options (20 minutes) +- --exitfirst +- --looponfailing - run large test set until all tests pass +- -k +- --exec +- mention the different options to control output +- 10 minute work time - exercises + +Branching out (20 minutes) +- generative tests +- skipping tests +- --pdb +- 10 minute work time - exercises Using existing extensions (30 minutes) - integrate collection/run of traditional unit-tests - run functions in their own tempdir - testing ReST documents +- skipping chunks within doctests - running Javascript tests +- continuous integration (running as part of a build)? + +Wrapping up and questions (20 minutes) +- where to go from here +- quesitons and student topics From briandorsey at codespeak.net Mon Nov 3 23:41:41 2008 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 3 Nov 2008 23:41:41 +0100 (CET) Subject: [py-svn] r59702 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103224141.11994169F94@codespeak.net> Author: briandorsey Date: Mon Nov 3 23:41:40 2008 New Revision: 59702 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Log: added initial reviewer's notes Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Mon Nov 3 23:41:40 2008 @@ -95,3 +95,17 @@ - quesitons and student topics +Notes for reviewers: +We're happy to adjust the content of the talk to match attendees interests and would greatly value reviewer input into specific areas they expect people to be interested (or not) in. + +Previous speaking/teaching experience: +Brian: +I co-presented a talk at PyCon last year and gave an earlier version of this +talk at the Vancouver Python Workshop. Most months, I moderate our loose +disscussion oriented meetings for the Seattle Python Interest Group. I'm +comfortable in front of audiences speaking and teaching. I taught High School +English in Japan for two years. For an example of my speaking style in short +talks, see: http://www.youtube.com/watch?v=2f4c1dQW3vY and a regular talk format from PyCon last year: http://www.youtube.com/watch?v=OCZ19R0KD4o This tutorial would be a different speaking style + +Holger: +XXX fill in previous speaking experience From briandorsey at codespeak.net Mon Nov 3 23:59:03 2008 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Mon, 3 Nov 2008 23:59:03 +0100 (CET) Subject: [py-svn] r59704 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081103225903.D9209169F95@codespeak.net> Author: briandorsey Date: Mon Nov 3 23:59:02 2008 New Revision: 59704 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Log: updated summary, started notes to reviewers Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Mon Nov 3 23:59:02 2008 @@ -28,15 +28,21 @@ Tutorial Summary: -XXX modify and refine +XXX: this needs to be shorter: max 100 words. -This tutorial introduces to automated testing for Python -and discusses basic usage of py.test. -We walk through the implementation of tests, layered setup of test state and debugging -facilities and point out differences to other test tools. XXX -We discuss and walk through the current feature set including -using and writing extensions for running Javascript tests or -testing the format of text documents. +This tutorial introduces automated testing for Python using py.test +(http://codespeak.net/py/dist/test.html). We begin with a very short overview +of testing in Python and where unit testing py.test fit in. The rest of the +tutorial is hands on: a short introduction of something new followed by +exercises to experiment with it. First is basic usage of py.test and the +features which simplify your test writing experience. We walk through the +implementation of tests, setup and teardown of test state, debugging +facilities and point out similarities/differences to other test tools. We talk +about command line options which save time running and debugging your tests. +We then drop briefly into lecture mode and discuss additional features useful +in particular circumstances, such as running Javascript tests, testing the +format of text documents, or using py.test in a build system. We will close +with time to answer questions and discuss topics from the students. Outline for review: From hpk at codespeak.net Tue Nov 4 02:09:50 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 4 Nov 2008 02:09:50 +0100 (CET) Subject: [py-svn] r59710 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081104010950.C703C169F98@codespeak.net> Author: hpk Date: Tue Nov 4 02:09:48 2008 New Revision: 59710 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Log: small amendments, fill in XXX Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Tue Nov 4 02:09:48 2008 @@ -1,7 +1,7 @@ Title: py.test - rapid testing with minimal effort Presenter: Brian Dorsey , Holger Krekel Tutorial format: interactive lecture -Recording: I give permission to record and publish my PyCon tutorial for free distribution. +Recording: We give permission to record and publish my PyCon tutorial for free distribution. Intended Audience: beginner programmers Maximum number of students: maybe 30 Perequisites/knowledge: basic knowledge of python programming @@ -48,7 +48,7 @@ Motivation / why automated testing? (10 minutes) - what is unit testing and how does it compare to other types of testing -- why do unit testing? benefits, etc +- why do automated testing? benefits, etc - existing python testing tools What you get with py.test (10 minutes) @@ -77,15 +77,15 @@ Options (20 minutes) - --exitfirst - --looponfailing - run large test set until all tests pass -- -k -- --exec -- mention the different options to control output +- -k to run tests matching name or keyword +- --exec to use different Python interpreters +- different options to control traceback generation - 10 minute work time - exercises Branching out (20 minutes) - generative tests - skipping tests -- --pdb +- --pdb - 10 minute work time - exercises Using existing extensions (30 minutes) @@ -114,4 +114,9 @@ talks, see: http://www.youtube.com/watch?v=2f4c1dQW3vY and a regular talk format from PyCon last year: http://www.youtube.com/watch?v=OCZ19R0KD4o This tutorial would be a different speaking style Holger: -XXX fill in previous speaking experience +I have talked at numerous Pycon and EuroPython conferences about +PyPyand testing tools. In 2008 i gave a 1h non-hands on version +of the proposed tutorial which was received very well. I've +also co-ordinated many sprints, gave teaching lectures +at university about computer science and generally enjoy +interacting with an interested learning group. From hpk at codespeak.net Tue Nov 4 02:13:24 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 4 Nov 2008 02:13:24 +0100 (CET) Subject: [py-svn] r59711 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081104011324.46505169F98@codespeak.net> Author: hpk Date: Tue Nov 4 02:13:23 2008 New Revision: 59711 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt Log: slight reformulation Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt Tue Nov 4 02:13:23 2008 @@ -8,36 +8,23 @@ Requirements: Attendees are welcome to bring their laptops with Python installed (version 2.4 or higher). Notes to reviewer: visting the beginner-oriented tutorial "rapid testing with minimal effort" is recommended, but not required. -Presenter bio: - -Holger Krekel is a co-founder of the PyPy project and -participates on many levels. He is the initiator and -maintainer of the popular py.test and a few other tools. In -2004 he founded merlinux, a company focusing on PyPy and py.test -developments. Holger has spoken at many EuroPython and -PyCon confereces and gave well received testing -tutorials at EuroPython 2008 and Pycon-UK 2008. - -XXX Brian - Tutorial Summary: -Interested to deepen your understanding of automated testing with Python? -To use a tool that allows to ad-hoc distribute tests to multiple +Want to know more about advanced automated testing with Python? +Use a tool that allows to ad-hoc distribute tests to multiple CPUs for speed and to multiple platforms for compatibility checks? With tons of debugging help for failure situations? This tutorial provides in-depth information on advanced usages -of the popular py.test tool. We discuss its current feature set +of the popular py.test tool. We highlight its current feature set including using and writing extensions for generating HTML pages, testing Javascript or ReST documents. We showcase and discuss ways of distributing tests across CPUs and platforms and will leave -time to discuss specific scenarios brought up during the session. +time to discuss and tackle specific scenarios brought up +during the session. The tutorial format will be an interactive lecture with plenty -of time for questions. We plan to host separate Open Space -time later in the conference for discussing things in a wider -audience. +of time for questions. Outline for review: From hpk at codespeak.net Tue Nov 4 06:38:32 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 4 Nov 2008 06:38:32 +0100 (CET) Subject: [py-svn] r59712 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081104053832.1A432169F9B@codespeak.net> Author: hpk Date: Tue Nov 4 06:38:30 2008 New Revision: 59712 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt Log: break time is not counted Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt Tue Nov 4 06:38:30 2008 @@ -42,7 +42,7 @@ - skipping chunks within doctests - looponfailing: run large test set until all tests pass -Using extensions (30 minutes) +Using extensions (40 minutes) - integrate collection/run of traditional unit-tests - run functions in their own tempdir - testing ReST documents @@ -50,7 +50,7 @@ - running Prolog tests - html reporting for nightly runs -Break (10 minutes) +Break Writing extensions (30 minutes) - overview on extensibility @@ -62,12 +62,12 @@ - test running hooks - writing cross-project plugins -Distributed testing (40 minutes) +Distributed testing (45 minutes) - motivation/vision - run your tests on multiple CPUs/multicore - running tests on multiple machines at once - running tests on windows, driven by Unix - do's and dont's for cross-process testing -Buffer, Q&A (20 minutes) +Buffer, Q&A (15 minutes) From briandorsey at codespeak.net Tue Nov 4 06:52:08 2008 From: briandorsey at codespeak.net (briandorsey at codespeak.net) Date: Tue, 4 Nov 2008 06:52:08 +0100 (CET) Subject: [py-svn] r59713 - py/extradoc/talk/pycon-us-2009 Message-ID: <20081104055208.41B56169FA3@codespeak.net> Author: briandorsey Date: Tue Nov 4 06:52:06 2008 New Revision: 59713 Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Log: Replaced extensions with doctests. Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-advanced.txt Tue Nov 4 06:52:06 2008 @@ -1,7 +1,7 @@ Title: py.test - cross-platform and distributed testing -Presenter: Holger Krekel , Brian +Presenter: Holger Krekel , Brian Tutorial format: interactive lecture -Recording: i give permission to record and publish my PyCon tutorial for free distribution. +Recording: I give permission to record and publish my PyCon tutorial for free distribution. Intended Audience: Python programmers Maximum number of students: maybe 30 Perequisites/knowledge: good knowledge of python programming, basic familiarity with automated testing @@ -11,9 +11,9 @@ Tutorial Summary: Want to know more about advanced automated testing with Python? -Use a tool that allows to ad-hoc distribute tests to multiple +Use a tool that allows you to ad-hoc distribute tests to multiple CPUs for speed and to multiple platforms for compatibility checks? -With tons of debugging help for failure situations? +With tons of debugging help in failure situations? This tutorial provides in-depth information on advanced usages of the popular py.test tool. We highlight its current feature set Modified: py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt ============================================================================== --- py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt (original) +++ py/extradoc/talk/pycon-us-2009/proposal-pytest-begin.txt Tue Nov 4 06:52:06 2008 @@ -74,7 +74,7 @@ Break -Options (20 minutes) +Options (25 minutes) - --exitfirst - --looponfailing - run large test set until all tests pass - -k to run tests matching name or keyword @@ -88,13 +88,11 @@ - --pdb - 10 minute work time - exercises -Using existing extensions (30 minutes) -- integrate collection/run of traditional unit-tests -- run functions in their own tempdir -- testing ReST documents -- skipping chunks within doctests -- running Javascript tests -- continuous integration (running as part of a build)? +Using doctests (25 minutes) +- what are doctests +- two usage scenarios - docstrings & stand alone files +- how they work demo and examples. +- 10 minute work time - exercises Wrapping up and questions (20 minutes) - where to go from here From hpk at codespeak.net Wed Nov 5 18:08:41 2008 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 5 Nov 2008 18:08:41 +0100 (CET) Subject: [py-svn] r59728 - py/trunk/contrib/pygreen/server Message-ID: <20081105170841.F13C8169E4A@codespeak.net> Author: hpk Date: Wed Nov 5 18:08:39 2008 New Revision: 59728 Modified: py/trunk/contrib/pygreen/server/httpserver.py Log: fix broken import exposed by a pypy test (bah) Modified: py/trunk/contrib/pygreen/server/httpserver.py ============================================================================== --- py/trunk/contrib/pygreen/server/httpserver.py (original) +++ py/trunk/contrib/pygreen/server/httpserver.py Wed Nov 5 18:08:39 2008 @@ -1,6 +1,6 @@ import BaseHTTPServer -from py.__.green import greensock2 -from py.__.green.pipe.gsocket import GreenSocket +from pygreen import greensock2 +from pygreen.pipe.gsocket import GreenSocket class GreenMixIn: From py-svn at codespeak.net Fri Nov 7 18:52:55 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Fri, 7 Nov 2008 18:52:55 +0100 (CET) Subject: [py-svn] important information Message-ID: <20081107175255.A29F416850C@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Sat Nov 8 11:28:38 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Sat, 8 Nov 2008 11:28:38 +0100 (CET) Subject: [py-svn] confirm please Message-ID: <20081108102838.A239D168450@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Sat Nov 8 20:53:07 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Sat, 8 Nov 2008 20:53:07 +0100 (CET) Subject: [py-svn] Virtual discounts are real Message-ID: <20081108195307.E5E1E168477@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Sat Nov 8 21:14:58 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Sat, 8 Nov 2008 21:14:58 +0100 (CET) Subject: [py-svn] Tiny dwarf is worse than a crime Message-ID: <20081108201458.3E2D8168478@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Sat Nov 8 21:42:09 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Sat, 8 Nov 2008 21:42:09 +0100 (CET) Subject: [py-svn] Huge pole brings her joy Message-ID: <20081108204209.B06A016848F@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Sun Nov 9 05:37:54 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Sun, 9 Nov 2008 05:37:54 +0100 (CET) Subject: [py-svn] Looking for great discounts on popilar pilules? Message-ID: <20081109043754.7C5BA168462@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Mon Nov 10 13:31:24 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Mon, 10 Nov 2008 13:31:24 +0100 (CET) Subject: [py-svn] Your personal video was sent by your wife Message-ID: <20081110123124.C00B31683F7@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Mon Nov 10 17:59:30 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Mon, 10 Nov 2008 17:59:30 +0100 (CET) Subject: [py-svn] Even kings consult our site Message-ID: <20081110165930.75A7C1684C5@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Tue Nov 11 03:28:53 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Tue, 11 Nov 2008 03:28:53 +0100 (CET) Subject: [py-svn] Even presidents use it Message-ID: <20081111022853.2379B168534@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Tue Nov 11 04:09:08 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Tue, 11 Nov 2008 04:09:08 +0100 (CET) Subject: [py-svn] Someone sent us your home video Message-ID: <20081111030908.6CB0B168510@codespeak.net> An HTML attachment was scrubbed... URL: From py-svn at codespeak.net Tue Nov 11 14:22:09 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Tue, 11 Nov 2008 14:22:09 +0100 (CET) Subject: [py-svn] Check how far her dark grotto goes Message-ID: <20081111132209.CAE66169E03@codespeak.net> An HTML attachment was scrubbed... URL: From fijal at codespeak.net Tue Nov 11 20:11:15 2008 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 11 Nov 2008 20:11:15 +0100 (CET) Subject: [py-svn] r59871 - py/trunk/py/code Message-ID: <20081111191115.AFFE7168554@codespeak.net> Author: fijal Date: Tue Nov 11 20:11:14 2008 New Revision: 59871 Modified: py/trunk/py/code/excinfo.py Log: yet-another-except when trying to get source Modified: py/trunk/py/code/excinfo.py ============================================================================== --- py/trunk/py/code/excinfo.py (original) +++ py/trunk/py/code/excinfo.py Tue Nov 11 20:11:14 2008 @@ -91,7 +91,10 @@ except KeyboardInterrupt: raise except: - s = str(source[-1]) + try: + s = str(source[-1]) + except: + return 0 return 4 + (len(s) - len(s.lstrip())) def _getentrysource(self, entry): From pedronis at codespeak.net Tue Nov 25 17:10:17 2008 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Tue, 25 Nov 2008 17:10:17 +0100 (CET) Subject: [py-svn] r60137 - in py/trunk/py: doc test test/testing Message-ID: <20081125161017.1382816843F@codespeak.net> Author: pedronis Date: Tue Nov 25 17:10:16 2008 New Revision: 60137 Modified: py/trunk/py/doc/test.txt py/trunk/py/test/pycollect.py py/trunk/py/test/testing/test_collect.py Log: support for explicitly named generative tests with tests and doc addition. Modified: py/trunk/py/doc/test.txt ============================================================================== --- py/trunk/py/doc/test.txt (original) +++ py/trunk/py/doc/test.txt Tue Nov 25 17:10:16 2008 @@ -136,6 +136,13 @@ to get run, notably ``check(42)``, ``check(17)`` and ``check(49)`` of which the middle one will obviously fail. +To make it easier to distinguish the generated tests it is possible to specify an explicit name for them, like for example:: + + def test_generative(): + for x in (42,17,49): + yield "case %d" % x, check, x + + .. _`selection by keyword`: selecting tests by keyword Modified: py/trunk/py/test/pycollect.py ============================================================================== --- py/trunk/py/test/pycollect.py (original) +++ py/trunk/py/test/pycollect.py Tue Nov 25 17:10:16 2008 @@ -268,19 +268,27 @@ self._setupstate.prepare(self) l = [] for i, x in py.builtin.enumerate(self.obj()): - call, args = self.getcallargs(x) + name, call, args = self.getcallargs(x) if not callable(call): raise TypeError("%r yielded non callable test %r" %(self.obj, call,)) - name = "[%d]" % i + if name is None: + name = "[%d]" % i + else: + name = "['%s']" % name l.append(self.Function(name, self, args=args, callobj=call)) return l def getcallargs(self, obj): - if isinstance(obj, (tuple, list)): - call, args = obj[0], obj[1:] + if not isinstance(obj, (tuple, list)): + obj = (obj,) + # explict naming + if isinstance(obj[0], basestring): + name = obj[0] + obj = obj[1:] else: - call, args = obj, () - return call, args + name = None + call, args = obj[0], obj[1:] + return name, call, args # # Test Items Modified: py/trunk/py/test/testing/test_collect.py ============================================================================== --- py/trunk/py/test/testing/test_collect.py (original) +++ py/trunk/py/test/testing/test_collect.py Tue Nov 25 17:10:16 2008 @@ -152,6 +152,48 @@ assert gencolitems[0].name == '[0]' assert gencolitems[0].obj.func_name == 'func1' + def test_generative_functions_with_explicit_names(self): + modcol = self.getmodulecol(""" + def func1(arg, arg2): + assert arg == arg2 + + def test_gen(): + yield "one", func1, 17, 3*5 + yield "two", func1, 42, 6*7 + """) + colitems = modcol.collect() + assert len(colitems) == 1 + gencol = colitems[0] + assert isinstance(gencol, py.test.collect.Generator) + gencolitems = gencol.collect() + assert len(gencolitems) == 2 + assert isinstance(gencolitems[0], py.test.collect.Function) + assert isinstance(gencolitems[1], py.test.collect.Function) + assert gencolitems[0].name == "['one']" + assert gencolitems[0].obj.func_name == 'func1' + assert gencolitems[1].name == "['two']" + assert gencolitems[1].obj.func_name == 'func1' + + def test_generative_methods_with_explicit_names(self): + modcol = self.getmodulecol(""" + def func1(arg, arg2): + assert arg == arg2 + class TestGenMethods: + def test_gen(self): + yield "m1", func1, 17, 3*5 + yield "m2", func1, 42, 6*7 + """) + gencol = modcol.collect()[0].collect()[0].collect()[0] + assert isinstance(gencol, py.test.collect.Generator) + gencolitems = gencol.collect() + assert len(gencolitems) == 2 + assert isinstance(gencolitems[0], py.test.collect.Function) + assert isinstance(gencolitems[1], py.test.collect.Function) + assert gencolitems[0].name == "['m1']" + assert gencolitems[0].obj.func_name == 'func1' + assert gencolitems[1].name == "['m2']" + assert gencolitems[1].obj.func_name == 'func1' + def test_module_assertion_setup(self): modcol = self.getmodulecol("pass") from py.__.magic import assertion From pedronis at codespeak.net Tue Nov 25 18:28:41 2008 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Tue, 25 Nov 2008 18:28:41 +0100 (CET) Subject: [py-svn] r60139 - py/trunk/py/code/testing Message-ID: <20081125172841.333D3168440@codespeak.net> Author: pedronis Date: Tue Nov 25 18:28:40 2008 New Revision: 60139 Modified: py/trunk/py/code/testing/test_code.py Log: some minimal testing for Code.source/fullsource Modified: py/trunk/py/code/testing/test_code.py ============================================================================== --- py/trunk/py/code/testing/test_code.py (original) +++ py/trunk/py/code/testing/test_code.py Tue Nov 25 18:28:40 2008 @@ -83,3 +83,19 @@ class A: pass py.test.raises(TypeError, "py.code.Code(A)") + +if True: + def x(): + pass + +def test_code_fullsource(): + code = py.code.Code(x) + full = code.fullsource + assert 'test_code_fullsource()' in str(full) + +def test_code_source(): + code = py.code.Code(x) + src = code.source() + expected = """def x(): + pass""" + assert str(src) == expected From pedronis at codespeak.net Tue Nov 25 18:32:05 2008 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Tue, 25 Nov 2008 18:32:05 +0100 (CET) Subject: [py-svn] r60140 - py/trunk/py/code Message-ID: <20081125173205.95B34168438@codespeak.net> Author: pedronis Date: Tue Nov 25 18:32:05 2008 New Revision: 60140 Modified: py/trunk/py/code/code.py Log: simplification, Source will invoke inspect.getsource on its own Modified: py/trunk/py/code/code.py ============================================================================== --- py/trunk/py/code/code.py (original) +++ py/trunk/py/code/code.py Tue Nov 25 18:32:05 2008 @@ -90,8 +90,7 @@ """ return a py.code.Source object for the code object's source only """ # return source only for that part of code - import inspect - return py.code.Source(inspect.getsource(self.raw)) + return py.code.Source(self.raw) def getargs(self): """ return a tuple with the argument names for the code object From pedronis at codespeak.net Tue Nov 25 19:34:48 2008 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Tue, 25 Nov 2008 19:34:48 +0100 (CET) Subject: [py-svn] r60141 - in py/trunk/py: code code/testing test Message-ID: <20081125183448.1756B168486@codespeak.net> Author: pedronis Date: Tue Nov 25 19:34:47 2008 New Revision: 60141 Modified: py/trunk/py/code/code.py py/trunk/py/code/source.py py/trunk/py/code/testing/test_excinfo.py py/trunk/py/code/testing/test_source.py py/trunk/py/code/traceback2.py py/trunk/py/test/pycollect.py Log: refactor things such that all fallbacks to inspect.get/findsource happen in helpers in source.py Modified: py/trunk/py/code/code.py ============================================================================== --- py/trunk/py/code/code.py (original) +++ py/trunk/py/code/code.py Tue Nov 25 19:34:47 2008 @@ -1,4 +1,5 @@ import py +from py.__.code import source class Code(object): """ wrapper around Python code objects """ @@ -75,14 +76,8 @@ def fullsource(self): """ return a py.code.Source object for the full source file of the code """ - fn = self.raw.co_filename - try: - return fn.__source__ - except AttributeError: - path = self.path - if not isinstance(path, py.path.local): - return None - return py.code.Source(self.path.read(mode="rU")) + full, _ = source.findsource(self.raw) + return full fullsource = property(fullsource, None, None, "full source containing this code object") Modified: py/trunk/py/code/source.py ============================================================================== --- py/trunk/py/code/source.py (original) +++ py/trunk/py/code/source.py Tue Nov 25 19:34:47 2008 @@ -223,6 +223,28 @@ class MyStr(str): """ custom string which allows to add attributes. """ +def findsource(obj): + if hasattr(obj, 'func_code'): + obj = obj.func_code + elif hasattr(obj, 'f_code'): + obj = obj.f_code + try: + fullsource = obj.co_filename.__source__ + except AttributeError: + try: + sourcelines, lineno = py.std.inspect.findsource(obj) + except (KeyboardInterrupt, SystemExit): + raise + except: + return None, None + source = Source() + source.lines = map(str.rstrip, sourcelines) + return source, lineno + else: + lineno = obj.co_firstlineno - 1 + return fullsource, lineno + + def getsource(obj, **kwargs): if hasattr(obj, 'func_code'): obj = obj.func_code @@ -240,7 +262,7 @@ else: lineno = obj.co_firstlineno - 1 end = fullsource.getblockend(lineno) - return fullsource[lineno:end+1] + return Source(fullsource[lineno:end+1], deident=True) def deindent(lines, offset=None): Modified: py/trunk/py/code/testing/test_excinfo.py ============================================================================== --- py/trunk/py/code/testing/test_excinfo.py (original) +++ py/trunk/py/code/testing/test_excinfo.py Tue Nov 25 19:34:47 2008 @@ -329,7 +329,7 @@ firstlineno = 5 def fullsource(self): - raise fail + return None fullsource = property(fullsource) class FakeFrame(object): Modified: py/trunk/py/code/testing/test_source.py ============================================================================== --- py/trunk/py/code/testing/test_source.py (original) +++ py/trunk/py/code/testing/test_source.py Tue Nov 25 19:34:47 2008 @@ -314,3 +314,43 @@ path.write(source) s2 = py.code.Source(tmpdir.join("a.py").pyimport().A) assert str(source).strip() == str(s2).strip() + +if True: + def x(): + pass + +def test_getsource_fallback(): + from py.__.code.source import getsource + expected = """def x(): + pass""" + src = getsource(x) + assert src == expected + +def test_getsource___source__(): + from py.__.code.source import getsource + x = py.code.compile("""if 1: + def x(): + pass +""") + + expected = """def x(): + pass""" + src = getsource(x) + assert src == expected + +def test_findsource_fallback(): + from py.__.code.source import findsource + src, lineno = findsource(x) + assert 'test_findsource_simple' in str(src) + assert src[lineno] == ' def x():' + +def test_findsource___source__(): + from py.__.code.source import findsource + x = py.code.compile("""if 1: + def x(): + pass +""") + + src, lineno = findsource(x) + assert 'if 1:' in str(src) + assert src[lineno] == ' def x():' Modified: py/trunk/py/code/traceback2.py ============================================================================== --- py/trunk/py/code/traceback2.py (original) +++ py/trunk/py/code/traceback2.py Tue Nov 25 19:34:47 2008 @@ -51,19 +51,9 @@ def getsource(self): """ return failing source code. """ - try: - source = self.frame.code.fullsource - except (IOError, py.error.ENOENT): - return None + source = self.frame.code.fullsource if source is None: - try: - sourcelines, lineno = py.std.inspect.findsource(self.frame.code.raw) - except (KeyboardInterrupt, SystemExit): - raise - except: - return None - source = py.code.Source() - source.lines = map(str.rstrip, sourcelines) + return None start = self.getfirstlinesource() end = self.lineno try: Modified: py/trunk/py/test/pycollect.py ============================================================================== --- py/trunk/py/test/pycollect.py (original) +++ py/trunk/py/test/pycollect.py Tue Nov 25 19:34:47 2008 @@ -18,6 +18,7 @@ """ import py from py.__.test.collect import configproperty, warnoldcollect +from py.__.code.source import findsource class PyobjMixin(object): def obj(): @@ -68,7 +69,7 @@ fspath = fn and py.path.local(fn) or None if fspath: try: - lines, lineno = py.std.inspect.findsource(self.obj) + _, lineno = findsource(self.obj) except IOError: lineno = None else: From pedronis at codespeak.net Tue Nov 25 20:15:03 2008 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Tue, 25 Nov 2008 20:15:03 +0100 (CET) Subject: [py-svn] r60142 - in py/trunk/py/test: . testing Message-ID: <20081125191503.E810D1683F4@codespeak.net> Author: pedronis Date: Tue Nov 25 20:15:01 2008 New Revision: 60142 Modified: py/trunk/py/test/pycollect.py py/trunk/py/test/testing/test_collect.py Log: - experimental support to let decorators used on tests specify a saner order by attaching the original function (we have been using something like this for quite a while at OE) - make the explicit names test more paranoid Modified: py/trunk/py/test/pycollect.py ============================================================================== --- py/trunk/py/test/pycollect.py (original) +++ py/trunk/py/test/pycollect.py Tue Nov 25 20:15:01 2008 @@ -60,16 +60,20 @@ return self._fslineno except AttributeError: pass + obj = self.obj + # let decorators etc specify a sane ordering + if hasattr(obj, 'place_as'): + obj = obj.place_as try: - code = py.code.Code(self.obj) + code = py.code.Code(obj) except TypeError: # fallback to - fn = (py.std.inspect.getsourcefile(self.obj) or - py.std.inspect.getfile(self.obj)) + fn = (py.std.inspect.getsourcefile(obj) or + py.std.inspect.getfile(obj)) fspath = fn and py.path.local(fn) or None if fspath: try: - _, lineno = findsource(self.obj) + _, lineno = findsource(obj) except IOError: lineno = None else: Modified: py/trunk/py/test/testing/test_collect.py ============================================================================== --- py/trunk/py/test/testing/test_collect.py (original) +++ py/trunk/py/test/testing/test_collect.py Tue Nov 25 20:15:01 2008 @@ -158,8 +158,8 @@ assert arg == arg2 def test_gen(): - yield "one", func1, 17, 3*5 - yield "two", func1, 42, 6*7 + yield "seventeen", func1, 17, 3*5 + yield "fortytwo", func1, 42, 6*7 """) colitems = modcol.collect() assert len(colitems) == 1 @@ -169,9 +169,9 @@ assert len(gencolitems) == 2 assert isinstance(gencolitems[0], py.test.collect.Function) assert isinstance(gencolitems[1], py.test.collect.Function) - assert gencolitems[0].name == "['one']" + assert gencolitems[0].name == "['seventeen']" assert gencolitems[0].obj.func_name == 'func1' - assert gencolitems[1].name == "['two']" + assert gencolitems[1].name == "['fortytwo']" assert gencolitems[1].obj.func_name == 'func1' def test_generative_methods_with_explicit_names(self): @@ -261,6 +261,28 @@ res2 = modcol.collect() assert res1 == [x.name for x in res2] + def test_allow_sane_sorting_for_decorators(self): + modcol = self.getmodulecol(""" + def dec(f): + g = lambda: f(2) + g.place_as = f + return g + + + def test_a(y): + pass + test_a = dec(test_a) + + def test_b(y): + pass + test_b = dec(test_b) + """) + colitems = modcol.collect() + assert len(colitems) == 2 + f1, f2 = colitems + assert cmp(f2, f1) > 0 + + class TestCustomConftests(suptest.InlineCollection): def test_extra_python_files_and_functions(self): self.makepyfile(conftest=""" From py-svn at codespeak.net Sun Nov 30 02:00:25 2008 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Sun, 30 Nov 2008 02:00:25 +0100 (CET) Subject: [py-svn] py-svn@codespeak.net, Buy One - Get Four Free! Message-ID: <20081130010025.B08671683C6@codespeak.net> An HTML attachment was scrubbed... URL: