Skip to content

Commit 4fa07f2

Browse files
author
nobody
committed
This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r37121]
1 parent c880e7d commit 4fa07f2

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

test/import_.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright Stefan Seefeld 2007.
2+
// Distributed under the Boost Software License, Version 1.0. (See
3+
// accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#include <boost/python.hpp>
7+
8+
#include <boost/detail/lightweight_test.hpp>
9+
#include <iostream>
10+
11+
12+
namespace bpl = boost::python;
13+
14+
void import_test()
15+
{
16+
// Retrieve the main module
17+
bpl::object import_ = bpl::import("import_");
18+
int value = bpl::extract<int>(import_.attr("value")) BOOST_EXTRACT_WORKAROUND;
19+
std::cout << value << std::endl;
20+
BOOST_TEST(value == 42);
21+
}
22+
23+
int main(int argc, char **argv)
24+
{
25+
// Initialize the interpreter
26+
Py_Initialize();
27+
28+
if (bpl::handle_exception(import_test))
29+
{
30+
if (PyErr_Occurred())
31+
{
32+
BOOST_ERROR("Python Error detected");
33+
PyErr_Print();
34+
}
35+
else
36+
{
37+
BOOST_ERROR("A C++ exception was thrown for which "
38+
"there was no exception handler registered.");
39+
}
40+
}
41+
42+
// Boost.Python doesn't support Py_Finalize yet.
43+
// Py_Finalize();
44+
return boost::report_errors();
45+
}
46+
47+
// Including this file makes sure
48+
// that on Windows, any crashes (e.g. null pointer dereferences) invoke
49+
// the debugger immediately, rather than being translated into structured
50+
// exceptions that can interfere with debugging.
51+
#include "module_tail.cpp"

test/import_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
value = 42

0 commit comments

Comments
 (0)