pytest-messenger icon indicating copy to clipboard operation
pytest-messenger copied to clipboard

Pytest-slack not Posting to Slack channel when using Pycharm Run option

Open lefty1975 opened this issue 3 years ago • 16 comments

"version": "==2.3.1"

I have my pytest.ini file configured to post my pytest results to a specific Slack channel, however, when I use the "Run" option in Pycharm my results are not being posted. But if I execute my tests from terminal, the report status is posted in the correct channel.

Before updating to this current version of pytest-slack, this was not an issue (2.2.4).

Not sure if this is a pytest-slack issue, or a Pycharm issue.

lefty1975 avatar Aug 06 '21 18:08 lefty1975

@lefty1975 check your Pycharm "Run" options, probably there are missed some cmd line options

LaserPhaser avatar Aug 07 '21 20:08 LaserPhaser

I have the same issue, I also tried working with the older version of pytest-slack (2.2.4) still not able to send the slack notification

surabhi-kinesso avatar Aug 12 '21 03:08 surabhi-kinesso

With version 2.2.4 I did not have to provide any cmd line arguments, but if you're indicating this is a must, it kind of feels like it goes against the grain of using a pytest.ini file.

lefty1975 avatar Aug 12 '21 15:08 lefty1975

will check how it works from pycharm thx for the report

LaserPhaser avatar Aug 12 '21 15:08 LaserPhaser

@lefty1975 could you please share "obfuscated" pytest.ini file

LaserPhaser avatar Aug 16 '21 08:08 LaserPhaser

yes, here it is with the slack key items removed.

pytest.ini.zip

lefty1975 avatar Aug 16 '21 14:08 lefty1975

@LaserPhaser I see pytest-slack is now called pytest-messenger. Since I have not received anymore updates regarding my original issue, would I benefit from uninstalling pytest-slack and installing pytest-messenger?

Additionally, when i tried installing pytest-messenger in parallel to pytest-slack, some of my other packages are being updated, for example: zipp = 3.6.0 > 3.7.0 Is there a way I can tell which of my existing packages will be updated when installing pytest-messenger?

If this is unclear, let me know and I will try to rephrase. I'm just merely a QA Tester trying to create chaos and prevent the rampant leakage of bugs.

lefty1975 avatar Jan 12 '22 20:01 lefty1975

Some additional information.

When I run my tests from terminal the addopts in my pytest.ini file are read and executed (including --slack_hook=https://hooks.slack.com/services).

However, when I run my tests using Pycharm's Run or Debug options most of my addopts are read and executed (e.g. --count=3 to repeat tests over and over), but --slack_hook=https://hooks.slack.com/services is not.

At this point I don't know if it's pytest-slack/messenger causing me this issue or if it's something with pycharm and how it reads my pytest.ini file when executing tests using Run/Debug options.

lefty1975 avatar Jan 13 '22 16:01 lefty1975

@LaserPhaser is this library no longer being attended to?

lefty1975 avatar Jan 12 '24 21:01 lefty1975

@lefty1975 it's still attended to.

LaserPhaser avatar Jan 14 '24 14:01 LaserPhaser

@LaserPhaser do you have any suggestions on what I might review to determine if this is an issue with this library or Pycharm?

  • Python 3.12.1
  • pytest-messenger 3.3.0
  • PyCharm 2023.2.5 (Community Edition) Build #PC-232.10227.11, built on November 13, 2023 Runtime version: 17.0.9+7-b1000.46 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows Server 2022 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 1500M Cores: 8 Non-Bundled Plugins: com.jetbrains.plugins.ini4idea (232.10227.13) com.intellij.plugin.adernov.powershell (2.3.1)

I appreciate any help you could provide.

lefty1975 avatar Jan 16 '24 14:01 lefty1975

@LaserPhaser do you have any suggestions on what I might review to determine if this is an issue with this library or Pycharm?

  • Python 3.12.1
  • pytest-messenger 3.3.0
  • PyCharm 2023.2.5 (Community Edition) Build #PC-232.10227.11, built on November 13, 2023 Runtime version: 17.0.9+7-b1000.46 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows Server 2022 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 1500M Cores: 8 Non-Bundled Plugins: com.jetbrains.plugins.ini4idea (232.10227.13) com.intellij.plugin.adernov.powershell (2.3.1)

I appreciate any help you could provide.

What exact problem do you have, could you please remind

LaserPhaser avatar Jan 16 '24 14:01 LaserPhaser

Pytest-slack not Posting to Slack channel when using Pycharm

Most of the details are above.

lefty1975 avatar Jan 16 '24 15:01 lefty1975

@lefty1975 sorry, but I can't reproduce it on my pycharm could you please give me MRE (minimal reproducible example)

LaserPhaser avatar Jan 26 '24 08:01 LaserPhaser

@LaserPhaser I created a new repo and invited you as a collaborator. It contains a simple test and a pytest.ini. When I run the test from the cmd-line, a Slack message is generated. However, when I run the same test using Pycharm's Run/Debug options a Slack message is never generated in the channel configured.

lefty1975 avatar Jan 29 '24 23:01 lefty1975

@LaserPhaser - I might be way off here, but I think the issue with using Pycharm's Run option lies within this Pytest hook @pytest.hookimpl(hookwrapper=True) def pytest_terminal_summary(terminalreporter, exitstatus, config):

Since the Run option outputs to a separate window than the terminal output, I don't think that hook is ever called. However, when I run pytest from the terminal the expected stats are sent to my slack channel.

lefty1975 avatar Feb 08 '24 16:02 lefty1975