当前位置: 首页>>代码示例>>Python>>正文


Python minimock.restore函数代码示例

本文整理汇总了Python中minimock.restore函数的典型用法代码示例。如果您正苦于以下问题:Python restore函数的具体用法?Python restore怎么用?Python restore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了restore函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tearDown

 def tearDown(self):
     """
     tearDown
     :return:
     """
     super(TestServer, self).tearDown()
     minimock.restore()
开发者ID:SalesSeek,项目名称:chaussette,代码行数:7,代码来源:test_server.py

示例2: test_get_client_invalid

    def test_get_client_invalid(self):
        """Test getting a connection

        """
        minimock.restore()
        mongothin.connection.register_connection("invalid", "mongothin", host="localhost", invalidaram="invalid")
        self.assertRaises(mongothin.connection.ConnectionError, mongothin.connection.get_connection, "invalid")
开发者ID:gilles,项目名称:mongothin,代码行数:7,代码来源:test_clients.py

示例3: test_parseUrl

    def test_parseUrl(self):
        "CSSParser.parseUrl()"
        if mock:
            # parseUrl(self, href, encoding=None, media=None, title=None):
            parser = cssutils.CSSParser()
            mock("cssutils.util._defaultFetcher", 
                 mock_obj=self._make_fetcher(None, u''))
            sheet = parser.parseUrl('http://example.com',
                                    media='tv,print', 
                                    title='test')
            restore()
            #self.assertEqual(sheet, 1)
            self.assertEqual(sheet.href, 'http://example.com')
            self.assertEqual(sheet.encoding, 'utf-8')
            self.assertEqual(sheet.media.mediaText, 'tv, print')
            self.assertEqual(sheet.title, 'test')
            
            # URL and content tests
            tests = {
                # (url, content): isSheet, encoding, cssText
                ('', None): (False, None, None), 
                ('1', None): (False, None, None), 
                ('mailto:[email protected]', None): (False, None, None), 
                ('http://example.com/x.css', None): (False, None, None), 
                ('http://example.com/x.css', ''): (True, u'utf-8', u''), 
               # ('http://example.com/x.css', 'a'): (True, u'utf-8', u''), 
#                ('http://example.com/x.css', 'a {color: red}'): (True, u'utf-8', 
#                                                                 u'a {\n    color: red\n    }'), 
#                ('http://example.com/x.css', 'a {color: red}'): (True, u'utf-8', 
#                                                                 u'a {\n    color: red\n    }'), 
#                ('http://example.com/x.css', '@charset "ascii";a {color: red}'): (True, u'ascii', 
#                                                                 u'@charset "ascii";\na {\n    color: red\n    }'), 
            }
            override = 'iso-8859-1'
            overrideprefix = u'@charset "iso-8859-1";'
            httpencoding = None
            
            for (url, content), (isSheet, expencoding, cssText) in tests.items():
                mock("cssutils.util._defaultFetcher", 
                     mock_obj=self._make_fetcher(httpencoding, content))
                #parser.setFetcher(self._make_fetcher(httpencoding, content))
                sheet1 = parser.parseUrl(url)
                sheet2 = parser.parseUrl(url, encoding=override)
                restore()
                if isSheet:
                    self.assertEqual(sheet1.encoding, expencoding)
                    self.assertEqual(sheet1.cssText, cssText)
                    self.assertEqual(sheet2.encoding, override)
                    if sheet1.cssText and sheet1.cssText.startswith('@charset'):
                        self.assertEqual(sheet2.cssText, cssText.replace('ascii', override))
                    elif sheet1.cssText:
                        self.assertEqual(sheet2.cssText, overrideprefix + '\n' + cssText)
                    else:
                        self.assertEqual(sheet2.cssText, overrideprefix + cssText)
                else:
                    self.assertEqual(sheet1, None)
                    self.assertEqual(sheet2, None)

            self.assertRaises(ValueError, parser.parseUrl, '../not-valid-in-urllib')
            self.assertRaises(urllib2.HTTPError, parser.parseUrl, 'http://example.com/not-present.css')
开发者ID:creativify,项目名称:information-overload,代码行数:60,代码来源:test_parse.py

示例4: testTripwireTripped

    def testTripwireTripped(self):
        '''Tripwire test, tripped'''
        tt = minimock.TraceTracker()
        minimock.mock('tripwire.sendEmail', tracker=tt)
        
        datevalue = datetime.date(2011, 8, 16)
        
        dtmock = minimock.Mock('datetime.date')
        minimock.mock('datetime.date', mock_obj=dtmock)
        dtmock.mock_returns = dtmock
        dtmock.today.mock_returns = datevalue
        dtmock.today.mock_tracker = tt
        #can't just do minimock.mock('datetime.date.today', returns=datevalue, tracker=tt)
        #because datetime.date is in an extension (ie, not native python)
        
        #Add another value to make the tripwire trip
        self.session.add(model.MeasuredValue(6))
        self.session.commit()
        
        tripwire.main()
        expected = r'''Called datetime.date.today()
Called tripwire.sendEmail(3.0, datetime.date(2011, 8, 16))'''
        self.assertTrue(tt.check(expected), tt.diff(expected))
        
        minimock.restore()
        
开发者ID:llnz,项目名称:kiwipycon2011testing,代码行数:25,代码来源:tripwiretest.py

示例5: test_ini_non_exist_or_bad

 def test_ini_non_exist_or_bad(self):
     """
     bad file
     """
     os.environ = minimock.Mock("os.environ")
     os.environ.get.mock_returns = "/tmp/tdtdtd"
     self.assertEqual(h.base.load_ini().sections(), [])
     minimock.restore()
开发者ID:seenxu,项目名称:simplexpense,代码行数:8,代码来源:test_helpers_base.py

示例6: test_env_not_set

 def test_env_not_set(self):
     """
     no ini set in environ
     """
     os.environ = minimock.Mock("os.environ")
     os.environ.get.mock_returns = None
     self.assertRaises(ValueError, h.base.load_ini)
     minimock.restore()
开发者ID:seenxu,项目名称:simplexpense,代码行数:8,代码来源:test_helpers_base.py

示例7: tearDown

 def tearDown(self):
   restore()
   try:
     # logging
     for record in self.log.records:
       if self.is_endpoints and len(record.args) >= 3:
         exception = record.args[2]
         if isinstance(exception, endpoints.ServiceException):
           try:
             str(exception)
           except TypeError:
             record.args[2].args = [str(arg) for arg in exception.args]
           except UnicodeEncodeError:
             record.args[2].args = [unicode(arg) for arg in exception.args]
       pathname = get_tail(record.pathname).group("tail")
       curdir_abspath = os.path.abspath(os.curdir)
       if is_mac:
         if curdir_abspath.startswith(mac_volumes_prefix):
           curdir_abspath = curdir_abspath[mac_volumes_prefix_length:]
         if pathname.startswith(mac_volumes_prefix):
           pathname = pathname[mac_volumes_prefix_length:]
       else:
         curdir_abspath = curdir_abspath.lstrip('/')
         pathname = pathname.lstrip('/')
       log = (record.levelname, pathname.replace(curdir_abspath, "").lstrip("/"), record.funcName, record.getMessage())
       if getattr(self, "expected_logs", None):
         if log in self.expected_logs:
           continue
         matched = None
         for expected_log in self.expected_logs:
           if "..." in expected_log[3]:
             if log[:2] == expected_log[:2]:
               if doctest._ellipsis_match(expected_log[3], log[3]):
                 matched = True
                 continue
         if matched:
           continue
       elif self.is_endpoints:
         expected_log = (
           'WARNING',
           'google/appengine/ext/ndb/tasklets.py',
           '_help_tasklet_along',
           '... generator ...(....py:...) raised ...Exception(...)')
         if log[:2] == expected_log[:2]:
           if doctest._ellipsis_match(expected_log[3], log[3]):
             matched = True
             continue
       print(record.levelname, pathname, record.lineno, record.funcName, record.getMessage())
       assert not log
   finally:
     self.log.clear()
     self.log.uninstall()
     # testbed
     self.testbed.deactivate()
     # os.environ
     for key, value in self.origin_environ.iteritems():
       if value is not None:
         os.environ[key] = value
开发者ID:MiCHiLU,项目名称:gae-tap,代码行数:58,代码来源:test_util.py

示例8: test_make_server_spawn

 def test_make_server_spawn(self):
     """
     Check the spawn option for the backend that support it
     :return:
     """
     for backend in ['gevent', 'fastgevent', 'geventwebsocket', 'socketio']:
         self.tt = minimock.TraceTracker()
         self._check_make_server_spawn(backend)
         minimock.restore()
开发者ID:SalesSeek,项目名称:chaussette,代码行数:9,代码来源:test_server.py

示例9: test_EncodeDataCheckProblemsFile_Exists

 def test_EncodeDataCheckProblemsFile_Exists(self):
     showname = "test show"
     inputname = "test input"
     outputname = "test_output_.mkv"
     data = EncodeData(showname, inputname, outputname)
     mock("os.path.exists", returns_iter=[False, True])
     result = data.checkproblems()
     self.assertIn("FILE_EXISTS", result)
     minimock.restore()
开发者ID:sfrischkorn,项目名称:recordingprocessing,代码行数:9,代码来源:libfilemanagertest.py

示例10: tearDown

    def tearDown(self):
        '''Clean up from each test case.

        Switch back to the original working directory, and clean up the test
        directory and any mocked objects.
        '''
        os.chdir(self.orig_cwd)
        self.test_dir.cleanup()
        minimock.restore()
开发者ID:me-and,项目名称:mdf,代码行数:9,代码来源:test.py

示例11: test_gpsdshm_Shm_error

def test_gpsdshm_Shm_error():
    gpsdshm.shm.shm_get = minimock.Mock("gpsdshm.shm.shm_get")
    gpsdshm.shm.shm_get.mock_returns = None
    try:
        gpsdshm.Shm()
    except OSError:
        minimock.restore()
        return
    raise Exception("gpsdshm.shm.shm_get did nto raise OSError")
开发者ID:mjuenema,项目名称:python-gpsdshm,代码行数:9,代码来源:test_gpsdshm.py

示例12: tearDown

 def tearDown(self):
     """
     tearDown
     :return:
     """
     super(TestServer, self).tearDown()
     minimock.restore()
     if self.old is not None:
         socket.socket.bind = self.old
开发者ID:Awingu,项目名称:chaussette,代码行数:9,代码来源:test_server.py

示例13: tearDown

    def tearDown(self):
        """Teardown

        """
        super(Testconnection, self).tearDown()
        mongothin.connection._connection_settings.clear()
        mongothin.connection._connections.clear()
        mongothin.connection._dbs.clear()
        minimock.restore()
开发者ID:gilles,项目名称:mongothin,代码行数:9,代码来源:test_clients.py

示例14: test_checkfileexistscaseinsensitive

    def test_checkfileexistscaseinsensitive(self):
        settings = Mock('libsettings.Settings')
        filemanager = FileManager(settings)

        mock("os.listdir", returns=["filename.test"])

        result = filemanager.checkfileexists("/path/to/fiLename.test", False)

        self.assertTrue(result)
        minimock.restore()
开发者ID:sfrischkorn,项目名称:recordingprocessing,代码行数:10,代码来源:libfilemanagertest.py

示例15: testTripwireNormal

 def testTripwireNormal(self):
     '''Tripwire test, not tripped'''
     tt = minimock.TraceTracker()
     minimock.mock('tripwire.sendEmail', tracker=tt)
     
     tripwire.main()
     
     self.assertTrue(tt.check(''), tt.diff(''))
     
     minimock.restore()
开发者ID:llnz,项目名称:kiwipycon2011testing,代码行数:10,代码来源:tripwiretest.py


注:本文中的minimock.restore函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。