Index: third_party/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc b/third_party/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc |
index 34f857fddb09369e2e39d2e07d683bc4c76f5bf4..23f2449cdecfdd31dc6766334d588b35d73cf4b4 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc |
+++ b/third_party/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc |
@@ -46,7 +46,6 @@ |
#include <google/protobuf/testing/file.h> |
#include <google/protobuf/testing/file.h> |
-#include <google/protobuf/stubs/strutil.h> |
#include <google/protobuf/testing/googletest.h> |
#include <gtest/gtest.h> |
@@ -116,53 +115,6 @@ TEST(PythonPluginTest, PluginTest) { |
EXPECT_EQ(0, cli.Run(5, argv)); |
} |
-// This test verifies that the generated Python output uses regular imports (as |
-// opposed to importlib) in the usual case where the .proto file paths do not |
-// not contain any Python keywords. |
-TEST(PythonPluginTest, ImportTest) { |
- // Create files test1.proto and test2.proto with the former importing the |
- // latter. |
- GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/test1.proto", |
- "syntax = \"proto3\";\n" |
- "package foo;\n" |
- "import \"test2.proto\";" |
- "message Message1 {\n" |
- " Message2 message_2 = 1;\n" |
- "}\n", |
- true)); |
- GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + "/test2.proto", |
- "syntax = \"proto3\";\n" |
- "package foo;\n" |
- "message Message2 {}\n", |
- true)); |
- |
- google::protobuf::compiler::CommandLineInterface cli; |
- cli.SetInputsAreProtoPathRelative(true); |
- python::Generator python_generator; |
- cli.RegisterGenerator("--python_out", &python_generator, ""); |
- string proto_path = "-I" + TestTempDir(); |
- string python_out = "--python_out=" + TestTempDir(); |
- const char* argv[] = {"protoc", proto_path.c_str(), "-I.", python_out.c_str(), |
- "test1.proto"}; |
- ASSERT_EQ(0, cli.Run(5, argv)); |
- |
- // Loop over the lines of the generated code and verify that we find an |
- // ordinary Python import but do not find the string "importlib". |
- string output; |
- GOOGLE_CHECK_OK(File::GetContents(TestTempDir() + "/test1_pb2.py", &output, |
- true)); |
- std::vector<string> lines = Split(output, "\n"); |
- string expected_import = "import test2_pb2"; |
- bool found_expected_import = false; |
- for (int i = 0; i < lines.size(); ++i) { |
- if (lines[i].find(expected_import) != string::npos) { |
- found_expected_import = true; |
- } |
- EXPECT_EQ(string::npos, lines[i].find("importlib")); |
- } |
- EXPECT_TRUE(found_expected_import); |
-} |
- |
} // namespace |
} // namespace python |
} // namespace compiler |