Repository: avocado-framework/avocado

Issue:
[Bug] Avocado crash with TypeError
With the following change on the time-sensitive job Avocado crashes:

```python
diff --git a/selftests/pre_release/jobs/timesensitive.py b/selftests/pre_release/jobs/timesensitive.py
index a9fbebcd..456719aa 100755
--- a/selftests/pre_release/jobs/timesensitive.py
+++ b/selftests/pre_release/jobs/timesensitive.py
@@ -4,6 +4,7 @@ import os
 import sys
 
 from avocado.core.job import Job
+from avocado.core.suite import TestSuite
 
 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(THIS_DIR)))
@@ -19,6 +20,7 @@ CONFIG = {
 
 
 if __name__ == '__main__':
-    with Job(CONFIG) as j:
+    suite = TestSuite.from_config(CONFIG)
+    with Job(CONFIG, [suite]) as j:
         os.environ['AVOCADO_CHECK_LEVEL'] = '3'
         sys.exit(j.run())
```

Crash:

```
[wrampazz@wrampazz avocado.dev]$ selftests/pre_release/jobs/timesensitive.py
JOB ID     : 5c1cf735be942802efc655a82ec84e46c1301080
JOB LOG    : /home/wrampazz/avocado/job-results/job-2020-08-27T16.12-5c1cf73/job.log

Avocado crashed: TypeError: expected str, bytes or os.PathLike object, not NoneType
Traceback (most recent call last):

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/core/job.py", line 605, in run_tests
    summary |= suite.run(self)

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/core/suite.py", line 266, in run
    return self.runner.run_suite(job, self)

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/plugins/runner_nrunner.py", line 237, in run_suite
    loop.run_until_complete(asyncio.wait_for(asyncio.gather(*workers),

  File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()

  File "/usr/lib64/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/core/task/statemachine.py", line 155, in run
    await self.start()

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/core/task/statemachine.py", line 113, in start
    start_ok = await self._spawner.spawn_task(runtime_task)

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/plugins/spawners/process.py", line 29, in spawn_task
    runtime_task.spawner_handle = await asyncio.create_subprocess_exec(

  File "/usr/lib64/python3.8/asyncio/subprocess.py", line 236, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(

  File "/usr/lib64/python3.8/asyncio/base_events.py", line 1630, in subprocess_exec
    transport = await self._make_subprocess_transport(

  File "/usr/lib64/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,

  File "/usr/lib64/python3.8/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,

  File "/usr/lib64/python3.8/asyncio/unix_events.py", line 789, in _start
    self._proc = subprocess.Popen(

  File "/usr/lib64/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,

  File "/usr/lib64/python3.8/subprocess.py", line 1637, in _execute_child
    self.pid = _posixsubprocess.fork_exec(

TypeError: expected str, bytes or os.PathLike object, not NoneType

Please include the traceback info and command line used on your bug report
Report bugs visiting https://github.com/avocado-framework/avocado/issues/new
```


Discussion:
@willianrampazzo can you try to create the Job also from_config ? `Job.from_config()` ? 
> @willianrampazzo can you try to create the Job also from_config ? `Job.from_config()` ?

Same crash:

```
diff --git a/selftests/pre_release/jobs/timesensitive.py b/selftests/pre_release/jobs/timesensitive.py
index a9fbebcd..90ba551b 100755
--- a/selftests/pre_release/jobs/timesensitive.py
+++ b/selftests/pre_release/jobs/timesensitive.py
@@ -19,6 +19,6 @@ CONFIG = {
 
 
 if __name__ == '__main__':
-    with Job(CONFIG) as j:
+    with Job.from_config(job_config=CONFIG) as j:
         os.environ['AVOCADO_CHECK_LEVEL'] = '3'
         sys.exit(j.run())
```

Crash:

```
[wrampazz@wrampazz avocado.dev]$ selftests/pre_release/jobs/timesensitive.py
JOB ID     : fa1f715a8fe69395f9961940c8f36072d1f92a44
JOB LOG    : /home/wrampazz/avocado/job-results/job-2020-08-27T16.28-fa1f715/job.log

Avocado crashed: TypeError: expected str, bytes or os.PathLike object, not NoneType
Traceback (most recent call last):

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/core/job.py", line 605, in run_tests
    summary |= suite.run(self)

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/core/suite.py", line 266, in run
    return self.runner.run_suite(job, self)

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/plugins/runner_nrunner.py", line 237, in run_suite
    loop.run_until_complete(asyncio.wait_for(asyncio.gather(*workers),

  File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()

  File "/usr/lib64/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/core/task/statemachine.py", line 155, in run
    await self.start()

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/core/task/statemachine.py", line 113, in start
    start_ok = await self._spawner.spawn_task(runtime_task)

  File "/home/wrampazz/src/avocado/avocado.dev/avocado/plugins/spawners/process.py", line 29, in spawn_task
    runtime_task.spawner_handle = await asyncio.create_subprocess_exec(

  File "/usr/lib64/python3.8/asyncio/subprocess.py", line 236, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(

  File "/usr/lib64/python3.8/asyncio/base_events.py", line 1630, in subprocess_exec
    transport = await self._make_subprocess_transport(

  File "/usr/lib64/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,

  File "/usr/lib64/python3.8/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,

  File "/usr/lib64/python3.8/asyncio/unix_events.py", line 789, in _start
    self._proc = subprocess.Popen(

  File "/usr/lib64/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,

  File "/usr/lib64/python3.8/subprocess.py", line 1637, in _execute_child
    self.pid = _posixsubprocess.fork_exec(

TypeError: expected str, bytes or os.PathLike object, not NoneType

Please include the traceback info and command line used on your bug report
Report bugs visiting https://github.com/avocado-framework/avocado/issues/new
```

Resolving patch:
diff --git a/selftests/pre_release/jobs/timesensitive.py b/selftests/pre_release/jobs/timesensitive.py
--- a/selftests/pre_release/jobs/timesensitive.py
+++ b/selftests/pre_release/jobs/timesensitive.py
@@ -14,11 +14,12 @@
     'run.references': [os.path.join(ROOT_DIR, 'selftests', 'unit'),
                        os.path.join(ROOT_DIR, 'selftests', 'functional')],
     'filter.by_tags.tags': ['parallel:1'],
+    'nrunner.status_server_uri': '127.0.0.1:8888',
     'nrunner.max_parallel_tasks': 1,
     }
 
 
 if __name__ == '__main__':
-    with Job(CONFIG) as j:
+    with Job.from_config(CONFIG) as j:
         os.environ['AVOCADO_CHECK_LEVEL'] = '3'
         sys.exit(j.run())


Test patch: