-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NameError: name 'QGISAPP' is not defined when using stop_app() #46883
Comments
Cannot reproduce on Linux/master: In [1]: from qgis.core import QgsApplication
...: from qgis.testing import start_app, stop_app
...:
...: print(f'About to start: {QgsApplication.instance()}', flush=True)
...: start_app()
...: print(f'About to stop: {QgsApplication.instance()}', flush=True)
...: stop_app()
...: print(f'Stopped: {QgsApplication.instance()}', flush=True)
About to start: None
../src/core/symbology/qgssymbollayerutils.cpp:1270 : (loadSymbol) [331ms] no layers for symbol
../src/core/symbology/qgssymbollayerutils.cpp:1270 : (loadSymbol) [1ms] no layers for symbol
../src/core/providers/qgsproviderregistry.cpp:329 : (init) [53ms] Loaded 24 providers (DB2;OAPIF;WFS;arcgisfeatureserver;arcgismapserver;delimitedtext;ept;gdal;geonode;gpx;mdal;memory;mesh_memory;mssql;ogr;oracle;postgres;postgresraster;spatialite;vectortile;virtual;virtualraster;wcs;wms)
Application state:
QGIS_PREFIX_PATH env var: /home/user/dev/QGIS/build-local-qt5152-release_gdal3/output
Prefix:
Plugin Path: /home/user/dev/QGIS/build-local-qt5152-release_gdal3/output/lib/qgis/plugins
Package Data Path: /home/user/dev/QGIS/build-local-qt5152-release_gdal3/output/data
Active Theme Name:
Active Theme Path: /home/user/dev/QGIS/build-local-qt5152-release_gdal3/output/data/resources/themes//icons/
Default Theme Path: :/images/themes/default/
SVG Search Paths: /home/user/dev/QGIS/build-local-qt5152-release_gdal3/output/data/svg/
/tmp/QGIS-PythonTestConfigPath6jgv6h4l/profiles/default/svg/
User DB Path: /home/user/dev/QGIS/build-local-qt5152-release_gdal3/output/data/resources/qgis.db
Auth DB Path: /home/user/tmp/qgis-auth.db
About to stop: <qgis._core.QgsApplication object at 0x7fec8eb22dc0>
Stopped: None |
On my windows system it still occurs. 3.23.0-Master 50a68d40d7
About to start: None
Application state:
QGIS_PREFIX_PATH env var: D:/OSGeo4W/apps/qgis-dev
Prefix: D:/OSGeo4W/apps/qgis-dev
Plugin Path: D:/OSGeo4W/apps/qgis-dev/plugins
Package Data Path: D:/OSGeo4W/apps/qgis-dev/.
Active Theme Name:
Active Theme Path: D:/OSGeo4W/apps/qgis-dev/./resources/themes\\icons/
Default Theme Path: :/images/themes/default/
SVG Search Paths: D:/OSGeo4W/apps/qgis-dev/./svg/
C:\Users\geo_beja\AppData\Local\Temp\QGIS-PythonTestConfigPath_koe8p7_\profiles\default/svg/
User DB Path: D:/OSGeo4W/apps/qgis-dev/./resources/qgis.db
Auth DB Path: C:\Users\geo_beja\AppData\Local\Temp\QGIS-PythonTestConfigPath_koe8p7_\profiles\default/qgis-auth.db
About to stop: <qgis._core.QgsApplication object at 0x0000025AAA833310>
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "D:\OSGeo4W\apps\qgis-dev\python\qgis\testing\__init__.py", line 518, in exitQgis
Stopped: None
QGISAPP.exitQgis()
NameError: name 'QGISAPP' is not defined
Process finished with exit code 0
|
The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". |
@elpaso have you tried running it from an IDE like QtCreator? # relates to https://github.com/qgis/QGIS/issues/46883
from qgis.core import QgsApplication, Qgis
from qgis.testing import start_app, stop_app
import unittest
print(Qgis.version(), Qgis.devVersion(), flush=True)
class TestQGISAPP(unittest.TestCase):
def test_StartAndClose(self):
print(f'About to start: {QgsApplication.instance()}', flush=True)
start_app()
print(f'About to stop: {QgsApplication.instance()}', flush=True)
stop_app()
print(f'Stopped: {QgsApplication.instance()}', flush=True)
if __name__ == '__main__':
unittest.main() Running this from QtCreator on Ubuntu still outputs the error. However, it's none-blocking, the test finishes well and I cannot figure out how to capture the NameError to let the unittest fail. |
The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". |
While we hate to see this happen, this issue has been automatically closed because it has not had any activity in the last 42 days despite being marked as feedback. If this issue should be reconsidered, please follow the guidelines in the previous comment and reopen this issue. |
What is the bug or the crash?
The qgs.testing package provides the
start_app
andstop_app
methods to run python tests.However, stopping the QgsApplication raises an anyoing, but none-blocking NameError:
Steps to reproduce the issue
Python code example:
Versions
3.23.0-Master a9b522f (OSGeo4W)
3.23.0-Master 90f8c88 (Ubuntu)
Supported QGIS version
New profile
Additional context
No response
The text was updated successfully, but these errors were encountered: