[Sugar-devel] [PATCH sugar 2/2] Allow to run tests without installing

Daniel Narvaez dwnarvaez at gmail.com
Fri Dec 7 09:12:27 EST 2012


From: Daniel Narvaez <dwnarvaez at gmail.com>

It's the common, expected behavior of unit tests and it makes
development faster.
---
 Makefile.am                  |    4 +++-
 tests/test_activitieslist.py |    6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index d024f44..2c406f8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
 TESTS_TMPDIR=$(abs_builddir)/tests-tmp
+TESTS_PYTHONPATH=$(abs_srcdir)/src:$(PYTHONPATH)
 
 SUBDIRS = bin data po src extensions
 
@@ -18,5 +19,6 @@ DISTCHECK_CONFIGURE_FLAGS = --disable-update-mimedb
 test:
 	cd $(top_srcdir)/tests && \
     mkdir -p $(TESTS_TMPDIR) && \
-    TMPDIR=$(TESTS_TMPDIR) python -m unittest discover && \
+    TMPDIR=$(TESTS_TMPDIR) PYTHONPATH=$(TESTS_PYTHONPATH) \
+    python -m unittest discover && \
     rm -rf $(TESTS_TMPDIR)
diff --git a/tests/test_activitieslist.py b/tests/test_activitieslist.py
index c5d13ab..a5a2e7c 100644
--- a/tests/test_activitieslist.py
+++ b/tests/test_activitieslist.py
@@ -20,8 +20,14 @@ import unittest
 from jarabe.desktop.activitieslist import ActivityListPalette
 
 tests_dir = os.path.dirname(__file__)
+base_dir = os.path.dirname(tests_dir)
 data_dir = os.path.join(tests_dir, "data")
 
+os.environ["SUGAR_ACTIVITIES_DEFAULTS"] = \
+    os.path.join(base_dir, "data", "activities.defaults")
+os.environ["SUGAR_MIME_DEFAULTS"] = \
+    os.path.join(base_dir, "data", "mime.defaults")
+
 class MockActivityInfo:
     def get_bundle_id(self):
         return "mock"
-- 
1.7.10.4



More information about the Sugar-devel mailing list