jazzband / django-auditlog

A Django app that keeps a log of changes made to an object.
MIT License
1.15k stars 414 forks source link

Tests run interactively don't strip escape codes in log line comparisons #644

Open SuperSandro2000 opened 6 months ago

SuperSandro2000 commented 6 months ago

When running the tests without piping into a program like cat, the escape codes are shown and the tests fail. The assertEqual should probably ignore those

image

full log

django-auditlog> building '/nix/store/71sm3q7rccgk804kz6f3yn3q27xz78kw-python3.11-django-auditlog-3.0.0.drv' on 'ssh-ng://amy.dse.in.tum.de'
copying 0 paths
django-auditlog> building '/nix/store/71sm3q7rccgk804kz6f3yn3q27xz78kw-python3.11-django-auditlog-3.0.0.drv'
django-auditlog> Sourcing python-remove-tests-dir-hook
django-auditlog> Sourcing python-catch-conflicts-hook.sh
django-auditlog> Sourcing python-remove-bin-bytecode-hook.sh
django-auditlog> Sourcing pypa-build-hook
django-auditlog> Using pypaBuildPhase
django-auditlog> Sourcing python-runtime-deps-check-hook
django-auditlog> Using pythonRuntimeDepsCheckHook
django-auditlog> Sourcing pypa-install-hook
django-auditlog> Using pypaInstallPhase
django-auditlog> Sourcing python-imports-check-hook.sh
django-auditlog> Using pythonImportsCheckPhase
django-auditlog> Sourcing python-namespaces-hook
django-auditlog> Sourcing python-catch-conflicts-hook.sh
django-auditlog> Running phase: unpackPhase
django-auditlog> unpacking source archive /nix/store/shyinm97sicfsbmr315z7zc4qq7gwspv-source
django-auditlog> source root is source
django-auditlog> setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/tox.ini
django-auditlog> Running phase: patchPhase
django-auditlog> Running phase: updateAutotoolsGnuConfigScriptsPhase
django-auditlog> Running phase: configurePhase
django-auditlog> no configure script, doing nothing
django-auditlog> Running phase: buildPhase
django-auditlog> Executing pypaBuildPhase
django-auditlog> Setting SETUPTOOLS_SCM_PRETEND_VERSION to 3.0.0
django-auditlog> Including all tracked files automatically
django-auditlog> Creating a wheel...
django-auditlog> * Getting build dependencies for wheel...
django-auditlog> * Building wheel...
django-auditlog> WARNING setuptools_scm.pyproject_reading toml section missing 'pyproject.toml does not contain a tool.setuptools_scm section'
django-auditlog> running bdist_wheel
django-auditlog> running build
django-auditlog> running build_py
django-auditlog> creating build
django-auditlog> creating build/lib
django-auditlog> creating build/lib/auditlog
django-auditlog> copying auditlog/middleware.py -> build/lib/auditlog
django-auditlog> copying auditlog/diff.py -> build/lib/auditlog
django-auditlog> copying auditlog/context.py -> build/lib/auditlog
django-auditlog> copying auditlog/conf.py -> build/lib/auditlog
django-auditlog> copying auditlog/apps.py -> build/lib/auditlog
django-auditlog> copying auditlog/receivers.py -> build/lib/auditlog
django-auditlog> copying auditlog/registry.py -> build/lib/auditlog
django-auditlog> copying auditlog/filters.py -> build/lib/auditlog
django-auditlog> copying auditlog/admin.py -> build/lib/auditlog
django-auditlog> copying auditlog/cid.py -> build/lib/auditlog
django-auditlog> copying auditlog/mixins.py -> build/lib/auditlog
django-auditlog> copying auditlog/signals.py -> build/lib/auditlog
django-auditlog> copying auditlog/models.py -> build/lib/auditlog
django-auditlog> copying auditlog/__init__.py -> build/lib/auditlog
django-auditlog> creating build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0006_object_pk_index.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0002_auto_support_long_primary_keys.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0004_logentry_detailed_object_repr.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0007_object_pk_type.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0011_logentry_serialized_data.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0009_alter_logentry_additional_data.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0010_alter_logentry_timestamp.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0008_action_index.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0001_initial.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0013_alter_logentry_timestamp.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0015_alter_logentry_changes.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/__init__.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0014_logentry_cid.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0012_add_logentry_action_access.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0005_logentry_additional_data_verbose_name.py -> build/lib/auditlog/migrations
django-auditlog> copying auditlog/migrations/0003_logentry_remote_addr.py -> build/lib/auditlog/migrations
django-auditlog> creating build/lib/auditlog/management
django-auditlog> copying auditlog/management/__init__.py -> build/lib/auditlog/management
django-auditlog> creating build/lib/auditlog/management/commands
django-auditlog> copying auditlog/management/commands/auditlogmigratejson.py -> build/lib/auditlog/management/commands
django-auditlog> copying auditlog/management/commands/auditlogflush.py -> build/lib/auditlog/management/commands
django-auditlog> copying auditlog/management/commands/__init__.py -> build/lib/auditlog/management/commands
django-auditlog> installing to build/bdist.linux-x86_64/wheel
django-auditlog> running install
django-auditlog> running install_lib
django-auditlog> creating build/bdist.linux-x86_64
django-auditlog> creating build/bdist.linux-x86_64/wheel
django-auditlog> creating build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/signals.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/diff.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> creating build/bdist.linux-x86_64/wheel/auditlog/management
django-auditlog> creating build/bdist.linux-x86_64/wheel/auditlog/management/commands
django-auditlog> copying build/lib/auditlog/management/commands/auditlogmigratejson.py -> build/bdist.linux-x86_64/wheel/auditlog/management/commands
django-auditlog> copying build/lib/auditlog/management/commands/__init__.py -> build/bdist.linux-x86_64/wheel/auditlog/management/commands
django-auditlog> copying build/lib/auditlog/management/commands/auditlogflush.py -> build/bdist.linux-x86_64/wheel/auditlog/management/commands
django-auditlog> copying build/lib/auditlog/management/__init__.py -> build/bdist.linux-x86_64/wheel/auditlog/management
django-auditlog> copying build/lib/auditlog/middleware.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/filters.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/conf.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/apps.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/cid.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/context.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/receivers.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/__init__.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/models.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/admin.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> creating build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0014_logentry_cid.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0015_alter_logentry_changes.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0007_object_pk_type.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0013_alter_logentry_timestamp.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0004_logentry_detailed_object_repr.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0011_logentry_serialized_data.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0008_action_index.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0002_auto_support_long_primary_keys.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0001_initial.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0006_object_pk_index.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0010_alter_logentry_timestamp.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0012_add_logentry_action_access.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/__init__.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0003_logentry_remote_addr.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0005_logentry_additional_data_verbose_name.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/migrations/0009_alter_logentry_additional_data.py -> build/bdist.linux-x86_64/wheel/auditlog/migrations
django-auditlog> copying build/lib/auditlog/mixins.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> copying build/lib/auditlog/registry.py -> build/bdist.linux-x86_64/wheel/auditlog
django-auditlog> running install_egg_info
django-auditlog> running egg_info
django-auditlog> creating django_auditlog.egg-info
django-auditlog> writing django_auditlog.egg-info/PKG-INFO
django-auditlog> writing dependency_links to django_auditlog.egg-info/dependency_links.txt
django-auditlog> writing requirements to django_auditlog.egg-info/requires.txt
django-auditlog> writing top-level names to django_auditlog.egg-info/top_level.txt
django-auditlog> writing manifest file 'django_auditlog.egg-info/SOURCES.txt'
django-auditlog> reading manifest file 'django_auditlog.egg-info/SOURCES.txt'
django-auditlog> reading manifest template 'MANIFEST.in'
django-auditlog> adding license file 'LICENSE'
django-auditlog> writing manifest file 'django_auditlog.egg-info/SOURCES.txt'
django-auditlog> Copying django_auditlog.egg-info to build/bdist.linux-x86_64/wheel/django_auditlog-3.0.0-py3.11.egg-info
django-auditlog> running install_scripts
django-auditlog> creating build/bdist.linux-x86_64/wheel/django_auditlog-3.0.0.dist-info/WHEEL
django-auditlog> creating '/build/source/dist/.tmp-ikt0qex9/django_auditlog-3.0.0-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
django-auditlog> adding 'auditlog/__init__.py'
django-auditlog> adding 'auditlog/admin.py'
django-auditlog> adding 'auditlog/apps.py'
django-auditlog> adding 'auditlog/cid.py'
django-auditlog> adding 'auditlog/conf.py'
django-auditlog> adding 'auditlog/context.py'
django-auditlog> adding 'auditlog/diff.py'
django-auditlog> adding 'auditlog/filters.py'
django-auditlog> adding 'auditlog/middleware.py'
django-auditlog> adding 'auditlog/mixins.py'
django-auditlog> adding 'auditlog/models.py'
django-auditlog> adding 'auditlog/receivers.py'
django-auditlog> adding 'auditlog/registry.py'
django-auditlog> adding 'auditlog/signals.py'
django-auditlog> adding 'auditlog/management/__init__.py'
django-auditlog> adding 'auditlog/management/commands/__init__.py'
django-auditlog> adding 'auditlog/management/commands/auditlogflush.py'
django-auditlog> adding 'auditlog/management/commands/auditlogmigratejson.py'
django-auditlog> adding 'auditlog/migrations/0001_initial.py'
django-auditlog> adding 'auditlog/migrations/0002_auto_support_long_primary_keys.py'
django-auditlog> adding 'auditlog/migrations/0003_logentry_remote_addr.py'
django-auditlog> adding 'auditlog/migrations/0004_logentry_detailed_object_repr.py'
django-auditlog> adding 'auditlog/migrations/0005_logentry_additional_data_verbose_name.py'
django-auditlog> adding 'auditlog/migrations/0006_object_pk_index.py'
django-auditlog> adding 'auditlog/migrations/0007_object_pk_type.py'
django-auditlog> adding 'auditlog/migrations/0008_action_index.py'
django-auditlog> adding 'auditlog/migrations/0009_alter_logentry_additional_data.py'
django-auditlog> adding 'auditlog/migrations/0010_alter_logentry_timestamp.py'
django-auditlog> adding 'auditlog/migrations/0011_logentry_serialized_data.py'
django-auditlog> adding 'auditlog/migrations/0012_add_logentry_action_access.py'
django-auditlog> adding 'auditlog/migrations/0013_alter_logentry_timestamp.py'
django-auditlog> adding 'auditlog/migrations/0014_logentry_cid.py'
django-auditlog> adding 'auditlog/migrations/0015_alter_logentry_changes.py'
django-auditlog> adding 'auditlog/migrations/__init__.py'
django-auditlog> adding 'django_auditlog-3.0.0.dist-info/LICENSE'
django-auditlog> adding 'django_auditlog-3.0.0.dist-info/METADATA'
django-auditlog> adding 'django_auditlog-3.0.0.dist-info/WHEEL'
django-auditlog> adding 'django_auditlog-3.0.0.dist-info/top_level.txt'
django-auditlog> adding 'django_auditlog-3.0.0.dist-info/RECORD'
django-auditlog> removing build/bdist.linux-x86_64/wheel
django-auditlog> Successfully built django_auditlog-3.0.0-py3-none-any.whl
django-auditlog> Finished creating a wheel...
django-auditlog> Finished executing pypaBuildPhase
django-auditlog> Running phase: pythonRuntimeDepsCheckHook
django-auditlog> Executing pythonRuntimeDepsCheck
django-auditlog> Checking runtime dependencies for django_auditlog-3.0.0-py3-none-any.whl
django-auditlog> Finished executing pythonRuntimeDepsCheck
django-auditlog> Running phase: installPhase
django-auditlog> Executing pypaInstallPhase
django-auditlog> Successfully installed django_auditlog-3.0.0-py3-none-any.whl
django-auditlog> Finished executing pypaInstallPhase
django-auditlog> Running phase: pythonOutputDistPhase
django-auditlog> Executing pythonOutputDistPhase
django-auditlog> Finished executing pythonOutputDistPhase
django-auditlog> Running phase: fixupPhase
django-auditlog> shrinking RPATHs of ELF executables and libraries in /nix/store/9gqbymldfr4fy0qk5c0rhajgqadaxzpx-python3.11-django-auditlog-3.0.0
django-auditlog> checking for references to /build/ in /nix/store/9gqbymldfr4fy0qk5c0rhajgqadaxzpx-python3.11-django-auditlog-3.0.0...
django-auditlog> patching script interpreter paths in /nix/store/9gqbymldfr4fy0qk5c0rhajgqadaxzpx-python3.11-django-auditlog-3.0.0
django-auditlog> stripping (with command strip and flags -S -p) in  /nix/store/9gqbymldfr4fy0qk5c0rhajgqadaxzpx-python3.11-django-auditlog-3.0.0/lib
django-auditlog> shrinking RPATHs of ELF executables and libraries in /nix/store/0m03bswvn4l6dl8d4sj6dzfyx5zgc030-python3.11-django-auditlog-3.0.0-dist
django-auditlog> checking for references to /build/ in /nix/store/0m03bswvn4l6dl8d4sj6dzfyx5zgc030-python3.11-django-auditlog-3.0.0-dist...
django-auditlog> patching script interpreter paths in /nix/store/0m03bswvn4l6dl8d4sj6dzfyx5zgc030-python3.11-django-auditlog-3.0.0-dist
django-auditlog> Executing pythonRemoveTestsDir
django-auditlog> Finished executing pythonRemoveTestsDir
django-auditlog> Running phase: installCheckPhase
django-auditlog> initializing postgresql
django-auditlog> The files belonging to this database system will be owned by user "nixbld".
django-auditlog> This user must also own the server process.
django-auditlog>
django-auditlog> The database cluster will be initialized with locale "C.UTF-8".
django-auditlog> The default database encoding has accordingly been set to "UTF8".
django-auditlog> The default text search configuration will be set to "english".
django-auditlog>
django-auditlog> Data page checksums are disabled.
django-auditlog>
django-auditlog> creating directory /build/postgresql ... ok
django-auditlog> creating subdirectories ... ok
django-auditlog> selecting dynamic shared memory implementation ... posix
django-auditlog> selecting default max_connections ... 100
django-auditlog> selecting default shared_buffers ... 128MB
django-auditlog> selecting default time zone ... UTC
django-auditlog> creating configuration files ... ok
django-auditlog> running bootstrap script ... ok
django-auditlog> performing post-bootstrap initialization ... ok
django-auditlog> syncing data to disk ... ok
django-auditlog>
django-auditlog> initdb: warning: enabling "trust" authentication for local connections
django-auditlog> initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
django-auditlog>
django-auditlog> Success. You can now start the database server using:
django-auditlog>
django-auditlog>     /nix/store/w9r8ij23dvrjlsbddizgqv3d1sngy0zb-postgresql-15.6/bin/pg_ctl -D /build/postgresql -l logfile start
django-auditlog>
django-auditlog> starting postgresql
django-auditlog> waiting for server to start....2024-05-16 09:22:03.985 UTC [346] LOG:  starting PostgreSQL 15.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 13.2.0, 64-bit
django-auditlog> 2024-05-16 09:22:03.986 UTC [346] LOG:  listening on Unix socket "/build/run/postgresql/.s.PGSQL.5432"
django-auditlog> 2024-05-16 09:22:03.988 UTC [349] LOG:  database system was shut down at 2024-05-16 09:22:03 UTC
django-auditlog> 2024-05-16 09:22:03.991 UTC [346] LOG:  database system is ready to accept connections
django-auditlog>  done
django-auditlog> server started
django-auditlog> setting up postgresql
django-auditlog> CREATE ROLE
django-auditlog> CREATE DATABASE
django-auditlog> Found 225 test(s).
django-auditlog> Creating test database for alias 'default'...
django-auditlog> System check identified no issues (0 silenced).
django-auditlog> ........FF...F...................................................................................................................................................................................................................
django-auditlog> ======================================================================
django-auditlog> FAIL: test_nothing_to_migrate (auditlog_tests.test_two_step_json_migration.AuditlogMigrateJsonTest.test_nothing_to_migrate)
django-auditlog> ----------------------------------------------------------------------
django-auditlog> Traceback (most recent call last):
django-auditlog>   File "/build/source/auditlog_tests/test_two_step_json_migration.py", line 56, in test_nothing_to_migrate
django-auditlog>     self.assertEqual(outbuf, msg)
django-auditlog> AssertionError: '\x1b[32;1mAll records have been migrated.\x1b[0m' != 'All records have been migrated.'
django-auditlog> - All records have been migrated.
django-auditlog> ? -------                               ----
django-auditlog> + All records have been migrated.
django-auditlog>
django-auditlog>
django-auditlog> ======================================================================
django-auditlog> FAIL: test_nothing_to_migrate_with_conf_true (auditlog_tests.test_two_step_json_migration.AuditlogMigrateJsonTest.test_nothing_to_migrate_with_conf_true)
django-auditlog> ----------------------------------------------------------------------
django-auditlog> Traceback (most recent call last):
django-auditlog>   File "/nix/store/czybdd31jfw5sr3p2j2mfqzhh8grbjq2-python3.11-django-4.2.11/lib/python3.11/site-packages/django/test/utils.py", line 461, in inner
django-auditlog>     return func(*args, **kwargs)
django-auditlog>            ^^^^^^^^^^^^^^^^^^^^^
django-auditlog>   File "/build/source/auditlog_tests/test_two_step_json_migration.py", line 67, in test_nothing_to_migrate_with_conf_true
django-auditlog>     self.assertEqual(outbuf, msg)
django-auditlog> AssertionError: '\x1b[32;1mAll records have been migrated.[96 chars]lse.' != 'All records have been migrated.\nYou can [62 chars]lse.'
django-auditlog> - All records have been migrated.
django-auditlog> ? -------                               ----
django-auditlog> + All records have been migrated.
django-auditlog> - You can now set AUDITLOG_USE_TEXT_CHANGES_IF_JSON_IS_NOT_PRESENT to False.?                 -------                                                ----
django-auditlog> + You can now set AUDITLOG_USE_TEXT_CHANGES_IF_JSON_IS_NOT_PRESENT to False.
django-auditlog>
django-auditlog> ======================================================================
django-auditlog> FAIL: test_using_django_with_error (auditlog_tests.test_two_step_json_migration.AuditlogMigrateJsonTest.test_using_django_with_error)
django-auditlog> ----------------------------------------------------------------------
django-auditlog> Traceback (most recent call last):
django-auditlog>   File "/build/source/auditlog_tests/test_two_step_json_migration.py", line 172, in test_using_django_with_error
django-auditlog>     self.assertEqual(msg, errbuf)
django-auditlog> AssertionError: 'ValueError was raised while converting th[85 chars][14]' != '\x1b[31;1mValueError was raised while con[102 chars]b[0m'
django-auditlog> - ValueError was raised while converting the logs with these ids into json.They where not be included in this migration batch.
django-auditlog> + ValueError was raised while converting the logs with these ids into json.They where not be included in this migration batch.
django-auditlog> ? +++++++
django-auditlog> - [14]+ [14]
django-auditlog>
django-auditlog> ----------------------------------------------------------------------
django-auditlog> Ran 225 tests in 2.550s
django-auditlog>
django-auditlog> FAILED (failures=3)
django-auditlog> Destroying test database for alias 'default'...
django-auditlog> 2024-05-16 09:22:07.413 UTC [347] LOG:  checkpoint starting: immediate force wait
django-auditlog> 2024-05-16 09:22:07.466 UTC [347] LOG:  checkpoint complete: wrote 927 buffers (5.7%); 1 WAL file(s) added, 0 removed, 0 recycled; write=0.010 s, sync=0.036 s, total=0.054 s; sync files=308, longest=0.001 s, average=0.001 s; distance=9964 kB, estimate=9964 kB