PythonPluginLoader_impl.h
Go to the documentation of this file.
/*
* Robot Testing Framework
*
* Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ROBOTTESTINGFRAMEWORK_PYTHONPLUGINLOADER_IMPL_H
#define ROBOTTESTINGFRAMEWORK_PYTHONPLUGINLOADER_IMPL_H
#include <robottestingframework/TestCase.h>
#include <Python.h>
#include <string>
namespace robottestingframework {
namespace plugin {
class PythonPluginLoaderImpl : public robottestingframework::TestCase
{
public:
PythonPluginLoaderImpl();
~PythonPluginLoaderImpl() override;
TestCase* open(const std::string filename);
void close();
std::string getLastError();
std::string getFileName();
void setTestName(const std::string name);
bool setup(int argc, char** argv) override;
void tearDown() override;
void run() override;
public:
static PyObject* setName(PyObject* self, PyObject* args);
static PyObject* assertError(PyObject* self, PyObject* args);
static PyObject* assertFail(PyObject* self, PyObject* args);
static PyObject* testReport(PyObject* self, PyObject* args);
static PyObject* testCheck(PyObject* self, PyObject* args);
private:
std::string getPythonErrorString();
private:
std::string filename;
std::string error;
PyObject* pyName;
PyObject* pyModule;
PyObject* pyDict;
PyObject* pyClass;
PyObject* pyInstance;
PyObject* pyModuleRobotTestingFramework;
PyObject* pyCapsuleRobotTestingFramework;
static PyMethodDef testPythonMethods[];
};
} // namespace robottestingframework
} // namespace plugin
#endif // ROBOTTESTINGFRAMEWORK_PYTHONPLUGINLOADER_IMPL_H
TestCase.h
robottestingframework::TestCase
The base class to implememnt a test case.
Definition: TestCase.h:42
robottestingframework::plugin::PythonPluginLoaderImpl
The PythonPluginLoaderImpl loads a Pthyon test case plug-in and gives the direct access to the TestCa...
Definition: PythonPluginLoader_impl.h:38
robottestingframework::plugin::PythonPluginLoaderImpl::pyModule
PyObject * pyModule
Definition: PythonPluginLoader_impl.h:103
robottestingframework::plugin::PythonPluginLoaderImpl::setTestName
void setTestName(const std::string name)
setTestName set the test case name
robottestingframework::plugin::PythonPluginLoaderImpl::getPythonErrorString
std::string getPythonErrorString()
robottestingframework::plugin::PythonPluginLoaderImpl::filename
std::string filename
Definition: PythonPluginLoader_impl.h:99
robottestingframework::plugin::PythonPluginLoaderImpl::setName
static PyObject * setName(PyObject *self, PyObject *args)
robottestingframework::plugin::PythonPluginLoaderImpl::pyCapsuleRobotTestingFramework
PyObject * pyCapsuleRobotTestingFramework
Definition: PythonPluginLoader_impl.h:108
robottestingframework::plugin::PythonPluginLoaderImpl::open
TestCase * open(const std::string filename)
open Loads a test case plugin
robottestingframework::plugin::PythonPluginLoaderImpl::pyModuleRobotTestingFramework
PyObject * pyModuleRobotTestingFramework
Definition: PythonPluginLoader_impl.h:107
robottestingframework::plugin::PythonPluginLoaderImpl::setup
bool setup(int argc, char **argv) override
setup is called before the test run.
robottestingframework::plugin::PythonPluginLoaderImpl::testReport
static PyObject * testReport(PyObject *self, PyObject *args)
robottestingframework::plugin::PythonPluginLoaderImpl::pyClass
PyObject * pyClass
Definition: PythonPluginLoader_impl.h:105
robottestingframework::plugin::PythonPluginLoaderImpl::run
void run() override
run is called by the TestCase class if setup is successfull;
robottestingframework::plugin::PythonPluginLoaderImpl::tearDown
void tearDown() override
tearDown is called after the test run
robottestingframework::plugin::PythonPluginLoaderImpl::testPythonMethods
static PyMethodDef testPythonMethods[]
Definition: PythonPluginLoader_impl.h:109
robottestingframework::plugin::PythonPluginLoaderImpl::assertError
static PyObject * assertError(PyObject *self, PyObject *args)
robottestingframework::plugin::PythonPluginLoaderImpl::close
void close()
close Unloads the plugin and deletes any allocated memory.
robottestingframework::plugin::PythonPluginLoaderImpl::pyName
PyObject * pyName
Definition: PythonPluginLoader_impl.h:102
robottestingframework::plugin::PythonPluginLoaderImpl::~PythonPluginLoaderImpl
~PythonPluginLoaderImpl() override
PythonPluginLoaderImpl destructor.
robottestingframework::plugin::PythonPluginLoaderImpl::PythonPluginLoaderImpl
PythonPluginLoaderImpl()
PythonPluginLoaderImpl constructor.
robottestingframework::plugin::PythonPluginLoaderImpl::error
std::string error
Definition: PythonPluginLoader_impl.h:100
robottestingframework::plugin::PythonPluginLoaderImpl::pyDict
PyObject * pyDict
Definition: PythonPluginLoader_impl.h:104
robottestingframework::plugin::PythonPluginLoaderImpl::testCheck
static PyObject * testCheck(PyObject *self, PyObject *args)
robottestingframework::plugin::PythonPluginLoaderImpl::assertFail
static PyObject * assertFail(PyObject *self, PyObject *args)
robottestingframework::plugin::PythonPluginLoaderImpl::getFileName
std::string getFileName()
getFileName returns the loaded script file name
robottestingframework::plugin::PythonPluginLoaderImpl::getLastError
std::string getLastError()
getLastError gets the last error if any.
robottestingframework::plugin::PythonPluginLoaderImpl::pyInstance
PyObject * pyInstance
Definition: PythonPluginLoader_impl.h:106
robottestingframework
Definition: Arguments.h:25