Esempio n. 1
0
 def __exit__(self, exception_type, value, tb):
     sys.settrace(None)
     for filename, functions in list(
             self.group_by_file(self._file_names, self._calls).items()):
         test = self._generator.dump(filename, functions)
         if self.verbose:
             print('=' * 47 + ' Auger ' + '=' * 46)
             print(test)
             print('=' * 100)
         else:
             modname = get_module_name(filename)
             if modname == '__main__':
                 modname = filename.replace('.py', '').capitalize()
             root = filename
             for _ in modname.split('.'):
                 root = os.path.dirname(root)
             output = os.path.normpath(
                 '%s/tests/test_%s.py' %
                 (root or '.', modname.replace('.', '_')))
             dir = os.path.dirname(output)
             if not os.path.exists(dir):
                 os.makedirs(dir)
             with open(output, 'w') as f:
                 f.write(test)
             print('Auger: generated test: %s' % output)
Esempio n. 2
0
 def __exit__(self, exception_type, value, tb):
     sys.settrace(None)
     subjects = self.group_by_file(self._file_names, self._calls)
     for filename, functions in subjects.items():
         modname = get_module_name(filename)
         root = filename
         for _ in modname.split('.'):
             root = os.path.dirname(root)
         output = os.path.normpath('%s/tests/test_%s.py' % (root, modname.replace('.', '_')))
         with open(output, 'w') as f:
             module = self._modules[self._file_names.index(filename)]
             f.write(self._generator.dump(filename, module, functions))
Esempio n. 3
0
 def get_modname(self, filename):
     return get_module_name(filename)