diff options
author | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2014-04-29 23:44:12 +0900 |
---|---|---|
committer | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2014-04-29 23:44:12 +0900 |
commit | 00eff0b7f656b5212b6f4d2c567f6828ee81ee82 (patch) | |
tree | c2c9028bcde9a51b75743a7b00d298da59e86e03 /tests/test_cpp_domain.py | |
parent | 91b9d75ac88afc349de4f8629b99c7fbcb3ff841 (diff) | |
download | sphinx-git-00eff0b7f656b5212b6f4d2c567f6828ee81ee82.tar.gz |
use six privided text_type() to replace with unicode() to support py2/py3 in one source. refs #1350.
Diffstat (limited to 'tests/test_cpp_domain.py')
-rw-r--r-- | tests/test_cpp_domain.py | 84 |
1 files changed, 43 insertions, 41 deletions
diff --git a/tests/test_cpp_domain.py b/tests/test_cpp_domain.py index 8e1cb22bb..1fec2ba29 100644 --- a/tests/test_cpp_domain.py +++ b/tests/test_cpp_domain.py @@ -9,6 +9,8 @@ :license: BSD, see LICENSE for details. """ +from six import text_type + from util import raises from sphinx.domains.cpp import DefinitionParser, DefinitionError @@ -20,100 +22,100 @@ def parse(name, string): def test_type_definitions(): rv = parse('member_object', ' const std::string & name = 42') - assert unicode(rv) == 'const std::string& name = 42' + assert text_type(rv) == 'const std::string& name = 42' rv = parse('member_object', ' const std::string & name leftover') - assert unicode(rv) == 'const std::string& name' + assert text_type(rv) == 'const std::string& name' rv = parse('member_object', ' const std::string & name [n] leftover') - assert unicode(rv) == 'const std::string& name[n]' + assert text_type(rv) == 'const std::string& name[n]' rv = parse('member_object', 'const std::vector< unsigned int, long> &name') - assert unicode(rv) == 'const std::vector<unsigned int, long>& name' + assert text_type(rv) == 'const std::vector<unsigned int, long>& name' x = 'std::vector<std::pair<std::string, int>>& module::test(register ' \ 'foo, bar, std::string baz="foobar, blah, bleh") const = 0' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'module::myclass::operator std::vector<std::string>()' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'explicit module::myclass::foo::foo()' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int printf(const char* fmt, ...)' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int foo(const unsigned int j)' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int foo(const unsigned int const j)' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int foo(const int* const ptr)' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'std::vector<std::pair<std::string, long long>> module::blah' - assert unicode(parse('type_object', x)) == x + assert text_type(parse('type_object', x)) == x - assert unicode(parse('type_object', 'long long int foo')) == 'long long foo' + assert text_type(parse('type_object', 'long long int foo')) == 'long long foo' x = 'void operator()(const boost::array<VertexID, 2>& v) const' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'void operator()(const boost::array<VertexID, 2, "foo, bar">& v) const' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'MyClass::MyClass(MyClass::MyClass&&)' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'constexpr int get_value()' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'static constexpr int get_value()' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int get_value() const noexcept' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int get_value() const noexcept = delete' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'MyClass::MyClass(MyClass::MyClass&&) = default' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'MyClass::a_virtual_function() const override' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'MyClass::a_member_function() volatile' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'MyClass::a_member_function() const volatile' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'MyClass::a_member_function() &&' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'MyClass::a_member_function() &' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'MyClass::a_member_function() const &' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int main(int argc, char* argv[][])' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'std::vector<std::pair<std::string, int>>& module::test(register ' \ 'foo, bar[n], std::string baz="foobar, blah, bleh") const = 0' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'module::myclass foo[n]' - assert unicode(parse('member_object', x)) == x + assert text_type(parse('member_object', x)) == x x = 'int foo(Foo f=Foo(double(), std::make_pair(int(2), double(3.4))))' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int foo(A a=x(a))' - assert unicode(parse('function', x)) == x + assert text_type(parse('function', x)) == x x = 'int foo(B b=x(a)' raises(DefinitionError, parse, 'function', x) @@ -127,31 +129,31 @@ def test_type_definitions(): def test_bases(): x = 'A' - assert unicode(parse('class', x)) == x + assert text_type(parse('class', x)) == x x = 'A : B' - assert unicode(parse('class', x)) == x + assert text_type(parse('class', x)) == x x = 'A : private B' - assert unicode(parse('class', x)) == 'A : B' + assert text_type(parse('class', x)) == 'A : B' x = 'A : public B' - assert unicode(parse('class', x)) == x + assert text_type(parse('class', x)) == x x = 'A : B, C' - assert unicode(parse('class', x)) == x + assert text_type(parse('class', x)) == x x = 'A : B, protected C, D' - assert unicode(parse('class', x)) == x + assert text_type(parse('class', x)) == x def test_operators(): x = parse('function', 'void operator new [ ] ()') - assert unicode(x) == 'void operator new[]()' + assert text_type(x) == 'void operator new[]()' x = parse('function', 'void operator delete ()') - assert unicode(x) == 'void operator delete()' + assert text_type(x) == 'void operator delete()' for op in '*-+=/%!': x = parse('function', 'void operator %s ()' % op) - assert unicode(x) == 'void operator%s()' % op + assert text_type(x) == 'void operator%s()' % op |