Rewrite how modpython loads modules

'imp' was deprecated since python 3.3.
This removes the undocumented feature of loading python C extension as
ZNC module, but adds a test that python package can be loaded.

Bump python requirements to 3.4
This commit is contained in:
Alexey Sokolov
2020-05-23 11:19:31 +01:00
parent 9a909b86b6
commit b3b38956a7
3 changed files with 128 additions and 46 deletions
+36
View File
@@ -243,5 +243,41 @@ TEST_F(ZNCTest, ModperlNV) {
client.ReadUntil(":a b");
}
TEST_F(ZNCTest, ModpythonPackage) {
if (QProcessEnvironment::systemEnvironment().value(
"DISABLED_ZNC_PERL_PYTHON_TEST") == "1") {
return;
}
auto znc = Run();
znc->CanLeak();
QDir dir(m_dir.path());
ASSERT_TRUE(dir.mkpath("modules"));
ASSERT_TRUE(dir.cd("modules"));
ASSERT_TRUE(dir.mkpath("packagetest"));
InstallModule("packagetest/__init__.py", R"(
import znc
from .data import value
class packagetest(znc.Module):
def OnModCommand(self, cmd):
self.PutModule('value = ' + value)
)");
InstallModule("packagetest/data.py", "value = 'a'");
auto ircd = ConnectIRCd();
auto client = LoginClient();
client.Write("znc loadmod modpython");
client.Write("znc loadmod packagetest");
client.Write("PRIVMSG *packagetest :foo");
client.ReadUntil("value = a");
InstallModule("packagetest/data.py", "value = 'b'");
client.Write("PRIVMSG *packagetest :foo");
client.ReadUntil("value = a");
client.Write("znc updatemod packagetest");
client.Write("PRIVMSG *packagetest :foo");
client.ReadUntil("value = b");
}
} // namespace
} // namespace znc_inttest