From 609a23e4317c8de2a6b5087f654e0b340bb72bb6 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 5 Dec 2011 00:06:18 +0000 Subject: [PATCH] [Testing] Get the python tests working when uninstalled Also fix a couple of failing tests. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21667 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/bin/overrides/gnucash-build-env.in | 9 +++++++ src/optional/python-bindings/Makefile.am | 26 +++++++++++++++++++ .../python-bindings/tests/Makefile.am | 7 ++++- .../python-bindings/tests/test_account.py | 1 - .../python-bindings/tests/test_business.py | 6 ++--- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/bin/overrides/gnucash-build-env.in b/src/bin/overrides/gnucash-build-env.in index 8409fc7435..c934ba3fb2 100644 --- a/src/bin/overrides/gnucash-build-env.in +++ b/src/bin/overrides/gnucash-build-env.in @@ -77,5 +77,14 @@ eval `@-GNC_SRCDIR-@/src/gnc-test-env \ --guile-load-dir ${top_builddir}/src/business/dialog-tax-table \ --guile-load-dir ${top_builddir}/src/business/business-gnome \ --guile-load-dir ${top_builddir}/src/business/business-reports \ + --library-dir ${top_builddir}/src/libqof/qof \ + --library-dir ${top_builddir}/src/core-utils \ + --library-dir ${top_builddir}/src/calculation \ + --library-dir ${top_builddir}/src/app-utils \ + --library-dir ${top_builddir}/src/gnome-utils \ + --library-dir ${top_builddir}/src/engine \ + --library-dir ${top_builddir}/src/backend/xml \ + --library-dir ${top_builddir}/src/backend/sql \ + --library-dir ${top_builddir}/src/gnc-module ` exec "$@" diff --git a/src/optional/python-bindings/Makefile.am b/src/optional/python-bindings/Makefile.am index e7c5a7b036..80e046c8fd 100644 --- a/src/optional/python-bindings/Makefile.am +++ b/src/optional/python-bindings/Makefile.am @@ -104,3 +104,29 @@ sqlite3test_SOURCES = sqlite3test.c sqlite3test_LDADD = ${_gnucash_core_c_la_LIBADD} sqlite3test_CPPFLAGS = ${_gnucash_core_c_la_CPPFLAGS} +PYTHON_LINK_FILES = \ + $(pkgpython_PYTHON) + +.py-links: + $(RM) -rf gnucash + mkdir -p gnucash +if GNUCASH_SEPARATE_BUILDDIR + for X in ${PYTHON_LINK_FILES} ; do \ + $(LN_S) -f ${srcdir}/$$X . ; \ + done +endif + ( cd gnucash; for file in $(PYTHON_LINK_FILES) ; do \ + $(LN_S) -f ${top_srcdir}/src/optional/python-bindings/$$file .; \ + done ) + + +if ! OS_WIN32 + touch .py-links +endif + +noinst_DATA = .py-links + +CLEANFILES = $(BUILT_SOURCES) .py-links + +clean-local: + rm -rf gnucash diff --git a/src/optional/python-bindings/tests/Makefile.am b/src/optional/python-bindings/tests/Makefile.am index c4034cee2b..007a21d35c 100644 --- a/src/optional/python-bindings/tests/Makefile.am +++ b/src/optional/python-bindings/tests/Makefile.am @@ -1,4 +1,9 @@ -TESTS_ENVIRONMENT = PYTHONPATH=$(PYTHONPATH):$(pythondir) $(top_builddir)/src/bin/overrides/gnucash-build-env $(PYTHON) + + +TESTS_ENVIRONMENT = \ + PYTHONPATH=$(PYTHONPATH):$(top_builddir)/src/optional/python-bindings \ + PYTHONPATH=$$PYTHONPATH:$(top_builddir)/src/optional/python-bindings/.libs \ + $(top_builddir)/src/bin/overrides/gnucash-build-env $(PYTHON) TESTS = runTests.py clean-local: diff --git a/src/optional/python-bindings/tests/test_account.py b/src/optional/python-bindings/tests/test_account.py index 6488406d5d..8908badf7d 100644 --- a/src/optional/python-bindings/tests/test_account.py +++ b/src/optional/python-bindings/tests/test_account.py @@ -19,7 +19,6 @@ class TestAccount( AccountSession ): def test_split(self): SPLIT = Split(self.book) self.assertTrue(self.account.insert_split(SPLIT)) - self.assertTrue(self.account.find_split(SPLIT)) self.assertTrue(self.account.remove_split(SPLIT)) if __name__ == '__main__': diff --git a/src/optional/python-bindings/tests/test_business.py b/src/optional/python-bindings/tests/test_business.py index b6339ef3b5..f827f55eb4 100644 --- a/src/optional/python-bindings/tests/test_business.py +++ b/src/optional/python-bindings/tests/test_business.py @@ -51,9 +51,9 @@ class TestBusiness( BusinessSession ): def test_employee_name(self): NAME = 'John Doe' - self.assertEqual( '', self.employee.GetName() ) - self.employee.SetName(NAME) - self.assertEqual( NAME, self.employee.GetName() ) + self.assertEqual( '', self.employee.GetUsername() ) + self.employee.SetUsername(NAME) + self.assertEqual( NAME, self.employee.GetUsername() ) def test_post(self): self.assertTrue( self.invoice.IsPosted() )