Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
test_pysupport.TestImportExisting Class Reference
Inheritance diagram for test_pysupport.TestImportExisting:
Inheritance graph
[legend]
Collaboration diagram for test_pysupport.TestImportExisting:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def testExisting
def createTestPlugin
def deleteTestPlugin
def setup_method
def checkPackage
def pluginExists
def pluginFilePath

Public Attributes

 key
 pluginDirectory

Static Public Attributes

string plugin = 'AutoCreatedMoinMoinTestPlugin'
 shouldDeleteTestPlugin = True
string name = 'Parser'

Detailed Description

Definition at line 79 of file test_pysupport.py.


Member Function Documentation

def test_pysupport.TestImportNameFromPlugin.checkPackage (   self,
  path 
) [inherited]

Definition at line 52 of file test_pysupport.py.

00052 
00053     def checkPackage(self, path):
00054         for item in (path, os.path.join(path, '__init__.py')):
00055             if not os.path.exists(item):
00056                 py.test.skip("Missing or wrong permissions: %s" % item)

Create test plugin, skiping if plugin exists 

Definition at line 104 of file test_pysupport.py.

00104 
00105     def createTestPlugin(self):
00106         """ Create test plugin, skiping if plugin exists """
00107         if self.pluginExists():
00108             self.shouldDeleteTestPlugin = False
00109             py.test.skip("Won't overwrite existing plugin: %s" % self.plugin)
00110         self.key = random_string(32, 'abcdefg')
00111         data = '''
00112 # If you find this file in your wiki plugin directory, you can safely
00113 # delete it.
00114 import sys, os
00115 
00116 class Parser:
00117     key = '%s'
00118 ''' % self.key
00119         try:
00120             file(self.pluginFilePath('.py'), 'w').write(data)
00121         except Exception, err:
00122             py.test.skip("Can't create test plugin: %s" % str(err))

Here is the call graph for this function:

Here is the caller graph for this function:

Delete plugin files ignoring missing files errors 

Definition at line 123 of file test_pysupport.py.

00123 
00124     def deleteTestPlugin(self):
00125         """ Delete plugin files ignoring missing files errors """
00126         if not self.shouldDeleteTestPlugin:
00127             return
00128         for suffix in ('.py', '.pyc'):
00129             try:
00130                 os.unlink(self.pluginFilePath(suffix))
00131             except OSError, err:
00132                 if err.errno != errno.ENOENT:
00133                     raise

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 57 of file test_pysupport.py.

00057 
00058     def pluginExists(self):
00059         return (os.path.exists(self.pluginFilePath('.py')) or
00060                 os.path.exists(self.pluginFilePath('.pyc')))

Here is the call graph for this function:

Here is the caller graph for this function:

def test_pysupport.TestImportNameFromPlugin.pluginFilePath (   self,
  suffix 
) [inherited]

Definition at line 61 of file test_pysupport.py.

00061 
00062     def pluginFilePath(self, suffix):
00063         return os.path.join(self.pluginDirectory, self.plugin + suffix)
00064 

Here is the caller graph for this function:

def test_pysupport.TestImportNameFromPlugin.setup_method (   self,
  method 
) [inherited]
Check for valid plugin package 

Definition at line 47 of file test_pysupport.py.

00047 
00048     def setup_method(self, method):
00049         """ Check for valid plugin package """
00050         self.pluginDirectory = os.path.join(self.request.cfg.data_dir, 'plugin', 'parser')
00051         self.checkPackage(self.pluginDirectory)

pysupport: import existing wiki plugin

Tests if a module can be imported from an arbitrary path
like it is done in moin for plugins. Some strange bug
in the old implementation failed on an import of os,
cause os does a from os.path import that will stumble
over a poisoned sys.modules.

Definition at line 84 of file test_pysupport.py.

00084 
00085     def testExisting(self):
00086         """ pysupport: import existing wiki plugin
00087 
00088         Tests if a module can be imported from an arbitrary path
00089         like it is done in moin for plugins. Some strange bug
00090         in the old implementation failed on an import of os,
00091         cause os does a from os.path import that will stumble
00092         over a poisoned sys.modules.
00093         """
00094         try:
00095             self.createTestPlugin()
00096             # clear the plugin cache...
00097             self.request.cfg._site_plugin_lists = {}
00098             parser = wikiutil.importWikiPlugin(self.request.cfg, 'parser',
00099                                                self.plugin, 'Parser')
00100             assert getattr(parser, '__name__', None) == 'Parser'
00101             assert parser.key == self.key
00102         finally:
00103             self.deleteTestPlugin()

Here is the call graph for this function:


Member Data Documentation

Definition at line 109 of file test_pysupport.py.

string test_pysupport.TestImportNameFromPlugin.name = 'Parser' [static, inherited]

Definition at line 45 of file test_pysupport.py.

string test_pysupport.TestImportExisting.plugin = 'AutoCreatedMoinMoinTestPlugin' [static]

Definition at line 81 of file test_pysupport.py.

Definition at line 49 of file test_pysupport.py.

Definition at line 82 of file test_pysupport.py.


The documentation for this class was generated from the following file: