landscape-bot: [![Code Health](https://landscape.io/badge/175759/landscape.svg?style=flat)](https://landscape.io/diff/163690)
Repository health decreased by 0.00% when pulling **[28cda3a](https://github.com/dlax/nose2/commit/28cda3abf4d51b58fd686b0b6c0ff5c46c38f51b) on dlax:generator-exception** into **[bf99453](https://github.com/nose-devs/nose2/commit/bf9945309d5118ad4723619452c486593964d1b8) on nose-devs:master**.

 * [1 new problem was found](https://landscape.io/diff/163690) (including 0 errors and 1 code smell).
 * [1 problem was fixed](https://landscape.io/diff/163690/fixed) (including 0 errors and 1 code smell).
coveralls: 
[![Coverage Status](https://coveralls.io/builds/2664738/badge)](https://coveralls.io/builds/2664738)

Coverage decreased (-0.06%) to 84.25% when pulling **28cda3abf4d51b58fd686b0b6c0ff5c46c38f51b on dlax:generator-exception** into **bf9945309d5118ad4723619452c486593964d1b8 on nose-devs:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/2664738/badge)](https://coveralls.io/builds/2664738)

Coverage decreased (-0.06%) to 84.25% when pulling **28cda3abf4d51b58fd686b0b6c0ff5c46c38f51b on dlax:generator-exception** into **bf9945309d5118ad4723619452c486593964d1b8 on nose-devs:master**.

landscape-bot: [![Code Health](https://landscape.io/badge/175789/landscape.svg?style=flat)](https://landscape.io/diff/163709)
Repository health increased by 0.07% when pulling **[ce05d05](https://github.com/dlax/nose2/commit/ce05d05f4ed1d9bb60cade4ccdb031637385585b) on dlax:generator-exception** into **[bf99453](https://github.com/nose-devs/nose2/commit/bf9945309d5118ad4723619452c486593964d1b8) on nose-devs:master**.

 * No new problems were introduced.
 * [1 problem was fixed](https://landscape.io/diff/163709/fixed) (including 0 errors and 1 code smell).
coveralls: 
[![Coverage Status](https://coveralls.io/builds/2664909/badge)](https://coveralls.io/builds/2664909)

Coverage increased (+0.02%) to 84.32% when pulling **ce05d05f4ed1d9bb60cade4ccdb031637385585b on dlax:generator-exception** into **bf9945309d5118ad4723619452c486593964d1b8 on nose-devs:master**.

dlax: Hmm, this does not actually fixes #48 completly since the exception context is not forwarded down to the test failure. Will work further on this...
dlax: Pushed a new version.
coveralls: 
[![Coverage Status](https://coveralls.io/builds/2668668/badge)](https://coveralls.io/builds/2668668)

Coverage decreased (-2.57%) to 81.73% when pulling **778265de7a289dda9ab9755ba2c08c89642b80ac on dlax:generator-exception** into **bf9945309d5118ad4723619452c486593964d1b8 on nose-devs:master**.

landscape-bot: [![Code Health](https://landscape.io/badge/176074/landscape.svg?style=flat)](https://landscape.io/diff/164010)
Code quality remained the same when pulling **[778265d](https://github.com/dlax/nose2/commit/778265de7a289dda9ab9755ba2c08c89642b80ac) on dlax:generator-exception** into **[bf99453](https://github.com/nose-devs/nose2/commit/bf9945309d5118ad4723619452c486593964d1b8) on nose-devs:master**.
diff --git a/nose2/loader.py b/nose2/loader.py
index 2778280..394899f 100644
--- a/nose2/loader.py
+++ b/nose2/loader.py
@@ -7,6 +7,8 @@
 import logging
 import traceback
 
+import six
+
 from nose2 import events
 from nose2.compat import unittest
 
@@ -114,7 +116,11 @@ class PluggableTestLoader(object):
 
     def _makeFailedTest(self, classname, methodname, exception):
         def testFailure(self):
-            raise exception
+            if isinstance(exception, Exception):
+                raise exception
+            else:
+                # exception tuple (type, value, traceback)
+                six.reraise(*exception)
         attrs = {methodname: testFailure}
         TestClass = type(classname, (unittest.TestCase,), attrs)
         return self.suiteClass((TestClass(methodname),))

Loader errors throw away tracebacks and exception detail
For instance if a generator test throws an AttributeError, the details of the attribute error are lost and the user only sees "AttributeError" -- not very helpful.
diff --git a/nose2/tests/unit/test_loader.py b/nose2/tests/unit/test_loader.py
index 24114e5..8dc152c 100644
--- a/nose2/tests/unit/test_loader.py
+++ b/nose2/tests/unit/test_loader.py
@@ -8,6 +8,21 @@ class TestPluggableTestLoader(TestCase):
         self.session = session.Session()
         self.loader = loader.PluggableTestLoader(self.session)
 
+    def test_failed_load_tests_exception(self):
+        suite = self.loader.failedLoadTests('test', RuntimeError('err'))
+        tc = suite._tests[0]
+        with self.assertRaises(RuntimeError) as cm:
+            tc.test()
+        self.assertEqual(cm.exception.args, ('err', ))
+
+    def test_failed_load_tests_exc_info(self):
+        suite = self.loader.failedLoadTests(
+            'test', (RuntimeError, RuntimeError('err'), None))
+        tc = suite._tests[0]
+        with self.assertRaises(RuntimeError) as cm:
+            tc.test()
+        self.assertEqual(cm.exception.args, ('err', ))
+
     def test_load_from_module_calls_hook(self):
         self.session.hooks.register('loadTestsFromModule', FakePlugin())
         evt = events.LoadFromModuleEvent(self.loader, 'some_module')

pip install -e .
parse_log_pytest
requirements.txt
nose2 pytest
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
cov-core==1.15.0
coverage==7.2.7
exceptiongroup==1.2.2
importlib-metadata==6.7.0
iniconfig==2.0.0
-e git+https://github.com/nose-devs/nose2.git@bf9945309d5118ad4723619452c486593964d1b8#egg=nose2
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
six==1.17.0
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0

name: nose2
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cov-core==1.15.0
      - coverage==7.2.7
      - exceptiongroup==1.2.2
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - six==1.17.0
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/nose2

nose2/tests/unit/test_loader.py::TestPluggableTestLoader::test_failed_load_tests_exc_info
nose2/tests/unit/test_loader.py::TestPluggableTestLoader::test_failed_load_tests_exception nose2/tests/unit/test_loader.py::TestPluggableTestLoader::test_load_from_module_calls_hook nose2/tests/unit/test_loader.py::TestPluggableTestLoader::test_load_from_name_calls_hook nose2/tests/unit/test_loader.py::TestPluggableTestLoader::test_load_from_names_calls_hook nose2/tests/unit/test_loader.py::TestPluggableTestLoader::test_loader_from_names_calls_module_hook nose2/tests/unit/test_loader.py::TestPluggableTestLoader::test_loader_from_names_calls_name_hook nose2/tests/unit/test_loader.py::TestPluggableTestLoader::test_loader_from_names_calls_names_hook
nose2/loader.py
nose2/loader.py