• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python minimock.restore函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_checkduplicatethomas

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

        os.walk = thomaswalk

        result = filemanager.checkduplicates("/path/to/S12E05 - Henry Gets It Wrong - SD TV.mkv")

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


示例17: test_checkduplicatesameextension

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

        os.walk = dummywalk

        result = filemanager.checkduplicates("/path/to/S03E14 - Test - SD TV.avi")

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


示例18: test_make_server

    def test_make_server(self):
        """
        Test all backends with default params
        :return:
        """

        # nose does not have great support for parameterized tests
        for backend in backends():
            self.tt = minimock.TraceTracker()
            self._check_make_server(backend)
            minimock.restore()
开发者ID:Awingu,项目名称:chaussette,代码行数:11,代码来源:test_server.py


示例19: test_fail_at_acquireWriteLock

 def test_fail_at_acquireWriteLock(self):
     self.setUpContext()
     mock('ReadWriteLock.acquireWriteLock', raises=Exception, tracker=None)
     self.assertRaises(Exception, self.context.dispatch, 'pseudo-init', self.obj)
     self.assertEqual(0, _FantasmFanIn.all().count())
     self.assertEqual(None, memcache.get('foo--InitialState--ok--FanInState--step-2-lock-3255389373'))
     restore()
     
     self.setUpContext(retryCount=1)
     self.context.dispatch('pseudo-init', self.obj)
     self.assertEqual(1, _FantasmFanIn.all().count())
     self.assertEqual('foo--InitialState--ok--FanInState--step-2-2957927341', 
                      _FantasmFanIn.all().get().workIndex)
     self.assertEqual('65536', memcache.get('foo--InitialState--ok--FanInState--step-2-lock-3255389373'))
开发者ID:iki,项目名称:fantasm,代码行数:14,代码来源:idempotency_test.py


示例20: test_resolveImports

    def test_resolveImports(self):
        "cssutils.resolveImports(sheet)"
        if mock:
            self._tempSer()
            cssutils.ser.prefs.useMinified()

            a = u'@charset "iso-8859-1";@import"b.css";ä{color:green}'.encode('iso-8859-1')
            b = u'@charset "ascii";\E4 {color:red}'.encode('ascii')
            
            # normal
            mock("cssutils.util._defaultFetcher", 
                 mock_obj=self._make_fetcher(None, b))
            s = cssutils.parseString(a)
            restore()            
            self.assertEqual(a, s.cssText)
            self.assertEqual(b, s.cssRules[1].styleSheet.cssText)
            c = cssutils.resolveImports(s)
            self.assertEqual('\xc3\xa4{color:red}\xc3\xa4{color:green}', 
                             c.cssText)

            c.encoding = 'ascii'
            self.assertEqual(r'@charset "ascii";\E4 {color:red}\E4 {color:green}', 
                             c.cssText)

            # b cannot be found
            mock("cssutils.util._defaultFetcher", 
                 mock_obj=self._make_fetcher(None, None))
            s = cssutils.parseString(a)
            restore()            
            self.assertEqual(a, s.cssText)
            self.assertEqual(None, s.cssRules[1].styleSheet)
            c = cssutils.resolveImports(s)
            self.assertEqual('@import"b.css";\xc3\xa4{color:green}', 
                             c.cssText)

            # @import with media
            a = u'@import"b.css";@import"b.css" print, tv ;@import"b.css" all;'
            b = u'a {color: red}'            
            mock("cssutils.util._defaultFetcher", 
                 mock_obj=self._make_fetcher(None, b))
            s = cssutils.parseString(a)
            restore()            
            c = cssutils.resolveImports(s)
            self.assertEqual('a{color:red}@media print,tv{a{color:red}}a{color:red}', 
                             c.cssText)
            
            # cannot resolve with media => keep original
            a = u'@import"b.css"print;'
            b = u'@namespace "http://example.com";'            
            mock("cssutils.util._defaultFetcher", 
                 mock_obj=self._make_fetcher(None, b))
            s = cssutils.parseString(a)
            restore()            
            c = cssutils.resolveImports(s)
            self.assertEqual(a, c.cssText)


            
        else:
            self.assertEqual(False, u'Minimock needed for this test')
开发者ID:cyberelfo,项目名称:casanova,代码行数:60,代码来源:test_cssutils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python clean.cleanup函数代码示例发布时间:2022-05-27
下一篇:
Python minimock.mock函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap