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


Python Timestamp.fromISOformat方法代码示例

本文整理汇总了Python中pywikibot.Timestamp.fromISOformat方法的典型用法代码示例。如果您正苦于以下问题:Python Timestamp.fromISOformat方法的具体用法?Python Timestamp.fromISOformat怎么用?Python Timestamp.fromISOformat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pywikibot.Timestamp的用法示例。


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

示例1: test_instantiate_from_instance

# 需要导入模块: from pywikibot import Timestamp [as 别名]
# 或者: from pywikibot.Timestamp import fromISOformat [as 别名]
 def test_instantiate_from_instance(self):
     """Test passing instance to factory methods works."""
     t1 = Timestamp.utcnow()
     self.assertIsNot(t1, Timestamp.fromISOformat(t1))
     self.assertEqual(t1, Timestamp.fromISOformat(t1))
     self.assertIsInstance(Timestamp.fromISOformat(t1), Timestamp)
     self.assertIsNot(t1, Timestamp.fromtimestampformat(t1))
     self.assertEqual(t1, Timestamp.fromtimestampformat(t1))
     self.assertIsInstance(Timestamp.fromtimestampformat(t1), Timestamp)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:11,代码来源:timestamp_tests.py

示例2: test_build_table_with_check

# 需要导入模块: from pywikibot import Timestamp [as 别名]
# 或者: from pywikibot.Timestamp import fromISOformat [as 别名]
 def test_build_table_with_check(self):
     """Test buildt table with check option."""
     bot = imagereview.CheckImageBot(check=True, total=0)
     bot.cat = 'Nonexisting page for imagereview'
     table = bot.build_table(save=False, unittest=True)
     if not table:
         self.skipTest('Table of files to review is empty')
     key = list(table.keys())[0]  # py3 comp
     data = table[key]
     item = data[0]
     self.assertIsInstance(key, StringTypes)
     self.assertIsInstance(data, list)
     self.assertIsInstance(item, list)
     self.assertEqual(len(item), 4)
     linkedtitle, uploader, filepage, reason = item
     user, time = uploader
     self.assertIsInstance(linkedtitle, StringTypes)
     self.assertIsInstance(uploader, list)
     self.assertIsInstance(filepage, imagereview.DUP_Image)
     self.assertIsInstance(reason, StringTypes)
     self.assertIsInstance(user, StringTypes)
     self.assertIsInstance(time, StringTypes)
     self.assertEqual(reason, '')
     self.assertEqual(filepage.title(asLink=True, textlink=True),
                      linkedtitle)
     self.assertEqual(user, key)
     self.assertIsInstance(Timestamp.fromISOformat(time), Timestamp)
开发者ID:edgarskos,项目名称:pywikibot-bots-xqbot,代码行数:29,代码来源:imagereview_tests.py

示例3: test_iso_format

# 需要导入模块: from pywikibot import Timestamp [as 别名]
# 或者: from pywikibot.Timestamp import fromISOformat [as 别名]
 def test_iso_format(self):
     t1 = T.utcnow()
     ts1 = t1.toISOformat()
     t2 = T.fromISOformat(ts1)
     ts2 = t2.toISOformat()
     # MediaWiki ISO format doesn't include microseconds
     self.assertNotEqual(t1, t2)
     t1 = t1.replace(microsecond=0)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
开发者ID:rubin16,项目名称:pywikibot-core,代码行数:12,代码来源:timestamp_tests.py

示例4: test_iso_format

# 需要导入模块: from pywikibot import Timestamp [as 别名]
# 或者: from pywikibot.Timestamp import fromISOformat [as 别名]
 def test_iso_format(self):
     """Test conversion from and to ISO format."""
     t1 = Timestamp.utcnow()
     ts1 = t1.isoformat()
     t2 = Timestamp.fromISOformat(ts1)
     ts2 = t2.isoformat()
     # MediaWiki ISO format doesn't include microseconds
     self.assertNotEqual(t1, t2)
     t1 = t1.replace(microsecond=0)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:13,代码来源:timestamp_tests.py

示例5: test_iso_format_with_sep

# 需要导入模块: from pywikibot import Timestamp [as 别名]
# 或者: from pywikibot.Timestamp import fromISOformat [as 别名]
 def test_iso_format_with_sep(self):
     """Test conversion from and to ISO format with separator."""
     SEP = '*'
     t1 = Timestamp.utcnow().replace(microsecond=0)
     ts1 = t1.isoformat(sep=SEP)
     t2 = Timestamp.fromISOformat(ts1, sep=SEP)
     ts2 = t2.isoformat(sep=SEP)
     self.assertEqual(t1, t2)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
     date, sep, time = ts1.partition(SEP)
     time = time.rstrip('Z')
     self.assertEqual(date, str(t1.date()))
     self.assertEqual(time, str(t1.time()))
开发者ID:magul,项目名称:pywikibot-core,代码行数:16,代码来源:timestamp_tests.py

示例6: test_iso_format

# 需要导入模块: from pywikibot import Timestamp [as 别名]
# 或者: from pywikibot.Timestamp import fromISOformat [as 别名]
 def test_iso_format(self):
     """Test conversion from and to ISO format."""
     SEP = 'T'
     t1 = Timestamp.utcnow()
     ts1 = t1.isoformat()
     t2 = Timestamp.fromISOformat(ts1)
     ts2 = t2.isoformat()
     # MediaWiki ISO format doesn't include microseconds
     self.assertNotEqual(t1, t2)
     t1 = t1.replace(microsecond=0)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
     date, sep, time = ts1.partition(SEP)
     time = time.rstrip('Z')
     self.assertEqual(date, str(t1.date()))
     self.assertEqual(time, str(t1.time()))
开发者ID:magul,项目名称:pywikibot-core,代码行数:18,代码来源:timestamp_tests.py


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