pynguin icon indicating copy to clipboard operation
pynguin copied to clipboard

ConstructionFailedException: Found no variables of type at position

Open tovmeod opened this issue 2 years ago • 8 comments

Hi,

First of all thank you for the project, I recently started playing with it and I am very impressed by the results.

I'm using a third party project as a test case (dnspython), with the following command line: pynguin --project-path . --output-path guin/dnsresults --module-name dns.ipv4

It successfully generates 6 test cases but it also outputs some errors, I'm not sure if they are expected or not, I'm looking for help to understand what is causing the error and what should I change so it can run successfully.

This is the code used: ipv4.py

ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ G:\envs\testccode\lib\site-packages\pynguin\testcase\testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ G:\envs\testccode\lib\site-packages\pynguin\testcase\testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ G:\envs\testccode\lib\site-packages\pynguin\testcase\testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.DNSException'> at position 2

tovmeod avatar Jul 10 '22 18:07 tovmeod

Dear @tovmeod ,

Thank you for your interest in Pynguin. Unfortunately, I've a very tight schedule this week, thus I'll not be able to look into your report this week. I'lol come back to your report next week.

Best, Stephan

stephanlukasczyk avatar Jul 11 '22 12:07 stephanlukasczyk

Dear @tovmeod ,

I have tried to replicate the issue using your given command line and Pynguin 0.25.2 (the latest release). Unfortunately, I was not successful in replicating. Pynguin yielded 84.2% coverage and exported six test cases, without raising the reported error. I have not specified a seed, since you did not do that either, thus my random seed was 1658492648501855000.

Could you please give me more details on Pynguin version, seed, etc. to allow me reproducing the issue? Besides, could you please check using the latest version of Pynguin if the bug is already fixed there?

Best, Stephan

stephanlukasczyk avatar Jul 22 '22 12:07 stephanlukasczyk

Thank you for your reply. In my test it was able to generate 6 tests cases, it does not seems to fail, but the output is printed while running. I ran it multiple times with similar results, I'm assuming the seed was different each time. If it makes any difference I'm on windows using wsl.

Where can I see the coverage yielded? should I run pytest with coverage?

tovmeod avatar Jul 25 '22 10:07 tovmeod

Inn my test it was able to generate 6 tests cases, it does not seems to fail, but the output is printed while running. I ran it multiple times with similar results, I'm assuming the seed was different each time.

If no seed is specified, Pynguin uses the current timestamp as yielded by time.time_ns() as its seed. The seed will thus be different for each execution; however, this may or may not influence the result (depends on seed, used algorithm, subject module, etc.).

If it makes any difference I'm on windows using wsl.

I don't know about Windows, I am not using it for like a decade. I am, however, not aware that it makes too much of a difference, whether running Pynguin on Linux, macOS, or WSL.

Where can I see the coverage yielded? should I run pytest with coverage?

You could use pytest for this. Pynguin also provides the coverage to standard output when specifying the option --statistics-backend CONSOLE. Please note that the results from Pynguin and PyTest might differ due to the way both compute their coverage values. We discuss this in our documentation. There we also show how to generate a coverage report as an HTML page, similar to the one emitted by pytest-cov.

I close the issue, because I think the original problem is solved. Feel free to post a follow up in case of further questions or issues.

stephanlukasczyk avatar Jul 25 '22 18:07 stephanlukasczyk

I'm still trying to understand the error messages printed while pynguin is running. Are they expected? what does they mean?

tovmeod avatar Jul 25 '22 19:07 tovmeod

Which error messages do you mean? Could you maybe paste me the full output, starting with the used command line, here for further investigation?

stephanlukasczyk avatar Jul 25 '22 19:07 stephanlukasczyk

this is the command: PYNGUIN_DANGER_AWARE=1 pynguin --project-path . --output-path guin/testdns --module-name dns.ipv4 full output:

[01:06:38] ERROR Cannot collect constants: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte constants.py:288 ╭─────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/analyses/constants.py:285 in collect_static_constants │ │ │ │ 282 │ for module in _find_modules_with_constants(project_path): │ │ 283 │ │ with open(os.path.join(project_path, module), encoding="utf-8") as module_file: │ │ 284 │ │ │ try: │ │ ❱ 285 │ │ │ │ tree = ast.parse(module_file.read()) │ │ 286 │ │ │ │ collector.visit(tree) │ │ 287 │ │ │ except BaseException as exception: # pylint: disable=broad-except │ │ 288 │ │ │ │ logger.exception("Cannot collect constants: %s", exception) │ │ │ │ /usr/lib/python3.10/codecs.py:322 in decode │ │ │ │ 319 │ def decode(self, input, final=False): │ │ 320 │ │ # decode input (taking the buffer into account) │ │ 321 │ │ data = self.buffer + input │ │ ❱ 322 │ │ (result, consumed) = self._buffer_decode(data, self.errors, final) │ │ 323 │ │ # keep undecoded input until the next call │ │ 324 │ │ self.buffer = data[consumed:] │ │ 325 │ │ return result │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte [01:06:46] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.DNSException'> at position 1 [01:07:37] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.DNSException'> at position 1 [01:08:38] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.ExceptionWrapper'> at position 1 [01:08:55] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.ExceptionWrapper'> at position 1 [01:11:47] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.ExceptionWrapper'> at position 1 [01:14:09] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.DNSException'> at position 2 [01:14:46] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.ExceptionWrapper'> at position 2 [01:14:48] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.DNSException'> at position 2 [01:15:09] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.DNSException'> at position 2 [01:15:34] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.DNSException'> at position 1 [01:15:39] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.ExceptionWrapper'> at position 1 [01:16:01] ERROR Failed to change call for statement. testfactory.py:757 ╭────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────╮ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:754 in change_random_call │ │ │ │ 751 │ │ │ │ 752 │ │ call = randomness.choice(calls) │ │ 753 │ │ try: │ │ ❱ 754 │ │ │ self.change_call(test_case, statement, call) │ │ 755 │ │ │ return True │ │ 756 │ │ except ConstructionFailedException: │ │ 757 │ │ │ self._logger.exception("Failed to change call for statement.") │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:782 in change_call │ │ │ │ 779 │ │ if call.is_method(): │ │ 780 │ │ │ method = cast(gao.GenericMethod, call) │ │ 781 │ │ │ assert method.owner │ │ ❱ 782 │ │ │ callee = self._get_random_non_none_object(test_case, method.owner, position) │ │ 783 │ │ │ parameters = self._get_reuse_parameters( │ │ 784 │ │ │ │ test_case, method.inferred_signature, position │ │ 785 │ │ │ ) │ │ │ │ /home/avraham/envs/testccode/lib/python3.10/site-packages/pynguin/testcase/testfactory.py:850 in get_random_non_none_object │ │ │ │ 847 │ │ │ ) │ │ 848 │ │ ] │ │ 849 │ │ if len(variables) == 0: │ │ ❱ 850 │ │ │ raise ConstructionFailedException( │ │ 851 │ │ │ │ f"Found no variables of type {type} at position {position}" │ │ 852 │ │ │ ) │ │ 853 │ │ return randomness.choice(variables) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ConstructionFailedException: Found no variables of type <class 'dns.exception.DNSException'> at position 2

tovmeod avatar Jul 26 '22 22:07 tovmeod

Hi, It seems that this is just excessive debug logging on our part, as the exception is just something that can happen during test case generation but is nothing that causes an actual error. As an end-user of Pynguin, there is also nothing you can do about it as it is simply caused by the probabilistic nature of Pynguin's algorithms. I will decrease the log level for this message so users are no longer spammed with this error.

Thanks again for reporting this :)

Best regards Florian

Wooza avatar Jul 27 '22 09:07 Wooza

Yesterday's release should have targeted this, thus I am closing the issue.

stephanlukasczyk avatar Sep 20 '22 13:09 stephanlukasczyk