Skip to content

get_data returning None on valid file path #6144

@AYUSHJAIN951

Description

@AYUSHJAIN951

Describe the bug
Test.get_data() returning None on valid file path, as it calls filename

possibly_compiled = inspect.getfile(self.__class__)

In the start of test, its called to fetch class module path, which occurs to be not absolute path, and which incurs issues when changing directories in test

This issue occurs upto python3.9 version, 3.10 onwards it works fine
But still on latest RHEL 3.9 is the default version, so should be fixed to provide absolute path of class module

Steps to reproduce

  1. Start a test using [test](https://github.com/avocado-framework/avocado/blob/master/avocado/core/test.py)
  2. check for logs: find Test metadata: in that filename parameter
python3.9.21
test.py
 
python3.10
/home/avocado-misc-tests/io/disk/test.py
 
python3.11
/home/avocado-misc-tests/io/disk/test.py

Here this filename is fetched using
inspect.getfile(self.__class__) -> which calls sys.modules.get(object.__module__)

Issue is occuring from here
sys.modules.get(object.__module__) this is returning localpath upto python3.9

python3.9.21
test.py
<module 'test' from 'test.py'>
 
python3.10
/home/avocado-misc-tests/io/disk/test.py
<module 'test' from '/home/avocado-misc-tests/io/disk/test.py'>
 
python3.11
/home/avocado-misc-tests/io/disk/test.py
<module 'test' from '/home/avocado-misc-tests/io/disk/test.py'>

Expected behavior
We expect absolute path for filename here

Current behavior
Local Path is returned in current state

System information (please complete the following information):

  • OS:
    NAME="Red Hat Enterprise Linux"
    VERSION="9.5 (Plow)"
    ID="rhel"
    ID_LIKE="fedora"
    VERSION_ID="9.5"
    PLATFORM_ID="platform:el9"
    PRETTY_NAME="Red Hat Enterprise Linux 9.5 (Plow)"

  • Avocado version: Avocado 109.0

  • Avocado installation method: github

$ python3.9 --version
Python 3.9.21

$ python3.9 -m pip --version
pip 21.3.1 from /usr/lib/python3.9/site-packages/pip (python 3.9)

$ python3.11 --version
Python 3.11.9

$ python3.11 -m pip --version
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done 113

Relationships

None yet

Development

No branches or pull requests

Issue actions