IronPython 有 unicodedata 模块吗?
我正在尝试获取与 IronPython 一起使用的 selenium2 Sauce OnDemand 服务的通用示例代码,用于我正在做的一些测试工作,但我遇到了一个我不太清楚的问题。
首先,这是环境:
Windows 7 Home Premium,64位。
.Net 4.0.30319.225 上的 IronPython 2.7.0.40
我的路径:
>>> sys.path
['.', 'C:\\users\\me\\scripts\\python', 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\Extensions\\Microsoft\\IronStudio\\0.4\\Lib', 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\Extensions\\Microsoft\\IronStudio\\0.4\\DLLs', 'C:\\opt\\win\\ipy\\Lib', 'C:\\opt\\win\\ipy\\DLLs', 'C:\\opt\\win\\ipy']
我知道 IronPython 在使用压缩 Egg 时存在问题,因此我将以下库提取到 sys.path 上的 \Lib 目录中:
selenium (2.0b4dev)
rdflib (3.1.0)
现在,来自 Sauce Labs 的示例代码:
import unittest
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class Selenium2OnSauce(unittest.TestCase):
def setUp(self):
desired_capabilities = dict(platform="WINDOWS",
browserName="firefox",
version="3.6",
name="Hello, Selenium 2!")
self.driver = webdriver.Remote(
desired_capabilities=desired_capabilities,
command_executor="http://me:[email protected]:80/wd/hub")
def test_sauce(self):
self.driver.get('http://example.saucelabs.com')
assert "Sauce Labs" in self.driver.title
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()
这是我收到的错误:
Traceback (most recent call last):
File "selenium2_test.py", line 3, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\__init__.py", line 18, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\firefox\webdriver.py", line 24, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\firefox\firefox_profile.py", line 23, in <module>
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\IronStudio\0.4\Lib\rdflib\__init__.py", line 65, in <module>
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\IronStudio\0.4\Lib\rdflib\namespace.py", line 282, in <module>
ImportError: No module named unicodedata
我尝试搜索其中包含 unicodedata 的包(例如 FePY),但没有它们似乎有效。我尝试从 Python27 安装中复制 .pyd,但这也不起作用。
这是 IronPython 2.7 中尚未提供的功能吗?或者,是否有我可以参考的库或命名空间来完成相同的任务?
如果没有,我想我将不得不放弃selenium2,直到铁人获得IP27的unicodedata。 :(
谢谢,
格雷格.
I'm trying to get the generic sample code for the selenium2 Sauce OnDemand service working with IronPython, for some test work I'm doing, and I've run into a problem I can't quite figure out.
First, Here's the environment:
Windows 7 Home Premium, 64bit.
IronPython 2.7.0.40 on .Net 4.0.30319.225
My path:
>>> sys.path
['.', 'C:\\users\\me\\scripts\\python', 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\Extensions\\Microsoft\\IronStudio\\0.4\\Lib', 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\Extensions\\Microsoft\\IronStudio\\0.4\\DLLs', 'C:\\opt\\win\\ipy\\Lib', 'C:\\opt\\win\\ipy\\DLLs', 'C:\\opt\\win\\ipy']
I'm aware that IronPython has issues using compressed eggs, so I've extracted the following libraries into the \Lib directory on the sys.path:
selenium (2.0b4dev)
rdflib (3.1.0)
Now, the sample code from Sauce Labs:
import unittest
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class Selenium2OnSauce(unittest.TestCase):
def setUp(self):
desired_capabilities = dict(platform="WINDOWS",
browserName="firefox",
version="3.6",
name="Hello, Selenium 2!")
self.driver = webdriver.Remote(
desired_capabilities=desired_capabilities,
command_executor="http://me:[email protected]:80/wd/hub")
def test_sauce(self):
self.driver.get('http://example.saucelabs.com')
assert "Sauce Labs" in self.driver.title
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()
Here's the error I'm getting:
Traceback (most recent call last):
File "selenium2_test.py", line 3, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\__init__.py", line 18, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\firefox\webdriver.py", line 24, in <module>
File "c:\opt\win\ipy\Lib\selenium\webdriver\firefox\firefox_profile.py", line 23, in <module>
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\IronStudio\0.4\Lib\rdflib\__init__.py", line 65, in <module>
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\IronStudio\0.4\Lib\rdflib\namespace.py", line 282, in <module>
ImportError: No module named unicodedata
I've tried searching for packages with unicodedata in them (such as FePY), but none of them seem to work. I've tried copying the .pyd from my Python27 installation, but that didn't work either.
Is this something that's not yet available in IronPython 2.7? Alternatively, is there a library or namespace I can reference to accomplish the same task?
If not, I guess I'll have to go without selenium2 until the Iron guys get a unicodedata for IP27. :(
Thanks,
Greg.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
遗憾的是,IronPython 目前不包含 unicodedata 模块。但不要害怕!即将发布的 2.7.1 版本将拥有它,您的所有烦恼将不再存在。
对此感到抱歉。至于2.7.1什么时候发布,我想是六月初。您可以检查 https://github.com/IronLanguages/main/commit/5395af28b5794b0acf982ab87d17466925ab819f 获取补丁,但由于包含 Unicode 数据库,它相当大且繁琐。
Alas, the unicodedata module is currently not included in IronPython. But fear not! For the upcoming 2.7.1 release will have it, and all of your troubles shall be no more.
Sorry about that. As for when 2.7.1 will be released, I'm thinking early June. You can check https://github.com/IronLanguages/main/commit/5395af28b5794b0acf982ab87d17466925ab819f for the patch, but it's fairly large and fiddly because of the included Unicode database.
请参阅@Micheal Greene 对原始问题的评论。这是按照指示进行编辑的模块:
See @Micheal Greene's comments on the original question. Here is the module with the edits as directed: