From 296a660a7391157c9317517e568d576ddb9d8a39 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 26 Jun 2009 17:48:46 +0200 Subject: [PATCH 1/2] doc refinements introduce '__channelexec__' + docs --HG-- branch : 1.0.x --- CHANGELOG | 2 ++ doc/announce/release-1.0.0.txt | 21 +++++++++++++-------- doc/execnet.txt | 16 ++++++++++++++++ py/__init__.py | 2 +- py/execnet/gateway.py | 2 +- py/execnet/testing/test_gateway.py | 5 +++++ 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f0a0e9e91..c1154857d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,8 @@ Changes between 1.0.0b3 and 1.0.0 * resolve issue #18, multiprocessing.Manager() and redirection clash +* make __name__ == "__channelexec__" for remote_exec code + Changes between 1.0.0b1 and 1.0.0b3 ============================================= diff --git a/doc/announce/release-1.0.0.txt b/doc/announce/release-1.0.0.txt index 372eaf9aa..b2eef241d 100644 --- a/doc/announce/release-1.0.0.txt +++ b/doc/announce/release-1.0.0.txt @@ -1,32 +1,37 @@ -py.test / py lib 1.0.0: distributed testing and dynamic code deployment +py.test / py lib 1.0.0: new test plugins, funcargs and cleanups ============================================================================ Welcome to the 1.0 release bringing new flexibility and power to testing with Python! Main news: -* new py.test plugin architecture, some examples: +* improved architecture, featuring simple single-file plugins, e.g: + pytest_unittest.py: run traditional unittest.py tests pytest_xfail.py: mark tests as "expected to fail" pytest_pocoo.py: automatically send tracebacks to pocoo paste service pytest_monkeypatch.py: safely patch parts of your environment in a test function pytest_figleaf.py: generate html coverage reports pytest_resultlog.py: generate buildbot-friendly output - and much more! + and many more! -* funcargs - the new flexible mechanism for managing all your test setup/fixture needs! +* funcargs - powerful mechanism for all your setup needs -* flexibly distribute tests to multiple computers from the command line +* distributed testing: ad-hoc send and run tests on many platforms + +* remove first round of non-test related code, notably + greenlets and apigen (documentation generation) that + now live on their own See the py.test documentation for more info: http://pytest.org -The py lib contains the py.test tool and offers its well-tested code -independently from the testing tool, mainly: +The py lib also got smaller and focuses on offering much of the +well-tested py.test code in independent namespaces: * py.execnet: ad-hoc code distribution to SSH, Socket and local sub processes -* py.code: support for dynamically running and debugging python code +* py.code: higher-level introspection and dynamic generation of python code * py.path: path abstractions over local and subversion files The whole package works well with Linux, OSX and Win32, on diff --git a/doc/execnet.txt b/doc/execnet.txt index 9a013dff8..baa8b7d41 100644 --- a/doc/execnet.txt +++ b/doc/execnet.txt @@ -233,3 +233,19 @@ socketserver:: socketgw = py.execnet.SocketGateway.new_remote(popengw, ("127.0.0.1", 0)) print socketgw._rinfo() # print some info about the remote environment + + +Sending a module / checking if run through remote_exec +-------------------------------------------------------------- + +You can pass a module object to ``remote_exec`` in which case +its source code will be sent. No dependencies will be transferred +so the module must be self-contained or only use modules that are +installed on the "other" side. Module code can detect if it is +running in a remote_exec situation by checking for the special +``__name__`` attribute like this:: + + if __name__ == '__channelexec__': + # ... call module functions ... + + diff --git a/py/__init__.py b/py/__init__.py index 1d156dacf..840f77681 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -19,7 +19,7 @@ For questions please check out http://pylib.org/contact.html """ from initpkg import initpkg -version = "1.0.0b5" +version = "1.0.0b6" initpkg(__name__, description = "py.test and pylib: advanced testing tool and networking lib", diff --git a/py/execnet/gateway.py b/py/execnet/gateway.py index 6a23c0d24..2ea35ae91 100644 --- a/py/execnet/gateway.py +++ b/py/execnet/gateway.py @@ -230,7 +230,7 @@ class Gateway(object): from sys import exc_info channel, (source, outid, errid) = item try: - loc = { 'channel' : channel } + loc = { 'channel' : channel, '__name__': '__channelexec__'} self._trace("execution starts:", repr(source)[:50]) close = self._local_redirect_thread_output(outid, errid) try: diff --git a/py/execnet/testing/test_gateway.py b/py/execnet/testing/test_gateway.py index f5bba5b90..750b3c964 100644 --- a/py/execnet/testing/test_gateway.py +++ b/py/execnet/testing/test_gateway.py @@ -92,6 +92,11 @@ class BasicRemoteExecution: def test_repr_doesnt_crash(self): assert isinstance(repr(self), str) + def test_attribute__name__(self): + channel = self.gw.remote_exec("channel.send(__name__)") + name = channel.receive() + assert name == "__channelexec__" + def test_correct_setup_no_py(self): channel = self.gw.remote_exec(""" import sys From 937e51b4ae8196733c80729a09f1a6aa7d973807 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 26 Jun 2009 18:12:06 +0200 Subject: [PATCH 2/2] improve docs some further, cleaner release announcement --HG-- branch : 1.0.x --- doc/announce/release-1.0.0.txt | 38 +++++++++++++++++++++------------- doc/test/funcargs.txt | 2 +- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/doc/announce/release-1.0.0.txt b/doc/announce/release-1.0.0.txt index b2eef241d..bf697a77d 100644 --- a/doc/announce/release-1.0.0.txt +++ b/doc/announce/release-1.0.0.txt @@ -2,26 +2,32 @@ py.test / py lib 1.0.0: new test plugins, funcargs and cleanups ============================================================================ Welcome to the 1.0 release bringing new flexibility and -power to testing with Python! Main news: +power to testing with Python. Main news: -* improved architecture, featuring simple single-file plugins, e.g: +* improved test architecture, featuring super-simple project + specific or cross-project single-file plugins, e.g: - pytest_unittest.py: run traditional unittest.py tests - pytest_xfail.py: mark tests as "expected to fail" - pytest_pocoo.py: automatically send tracebacks to pocoo paste service - pytest_monkeypatch.py: safely patch parts of your environment in a test function - pytest_figleaf.py: generate html coverage reports - pytest_resultlog.py: generate buildbot-friendly output + * pytest_unittest.py: run traditional unittest.py tests + * pytest_xfail.py: mark tests as "expected to fail" + * pytest_pocoo.py: automatically send tracebacks to pocoo paste service + * pytest_monkeypatch.py: safely patch parts of your environment in a test function + * pytest_figleaf.py: generate html coverage reports + * pytest_resultlog.py: generate buildbot-friendly output - and many more! + and many more! -* funcargs - powerful mechanism for all your setup needs +* funcargs - bringing new flexibilty and zero-boilerplate to Python testing: -* distributed testing: ad-hoc send and run tests on many platforms + - cleanly separated test code and test configuration and test value setup + - ideal for integration and functional tests + - new generative tests -> deprecation of yield-generated tests + +* distributed testing and distributed execution (py.execnet): + + - new unified "TX" URL scheme for specifying remote resources + - new sync/async ways to handle multiple remote processes + - much improved documentation -* remove first round of non-test related code, notably - greenlets and apigen (documentation generation) that - now live on their own See the py.test documentation for more info: @@ -34,6 +40,10 @@ well-tested py.test code in independent namespaces: * py.code: higher-level introspection and dynamic generation of python code * py.path: path abstractions over local and subversion files +Some non-strictly-test related code, notably greenlets/co-routines +and apigen now live on their own and have been removed, also simplifying +the installation procedures. + The whole package works well with Linux, OSX and Win32, on Python 2.3, 2.4, 2.5 and 2.6. (Expect Python3 compatibility soon!) diff --git a/doc/test/funcargs.txt b/doc/test/funcargs.txt index 45cdb137b..187771f0a 100644 --- a/doc/test/funcargs.txt +++ b/doc/test/funcargs.txt @@ -39,7 +39,7 @@ convenient enough to .. _`funcarg provider`: -funcarg providers: setting up test function arguments +funcarg providers: instantiating test function arguments ============================================================== Test functions can specify one ore more arguments ("funcargs")