Skip to content

Commit

Permalink
mock GITHUB_REPOSITORY
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Apr 1, 2024
1 parent 3fa8f13 commit bcc5001
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/test_dev.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import warnings
import datetime
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch

import pytest
from monty.dev import deprecated, install_excepthook, requires
Expand Down Expand Up @@ -91,12 +91,18 @@ def classmethod_b(cls):

def test_deprecated_deadline(self, monkeypatch):
with pytest.raises(DeprecationWarning):
monkeypatch.setenv("CI", "true")
monkeypatch.setenv("GITHUB_REPOSITORY", "materialsvirtuallab/monty")

@deprecated(deadline=(2000, 1, 1))
def func_old():
pass
monkeypatch.setenv("CI", "true") # mock CI env

with patch("subprocess.run") as mock_run:
# Mock "GITHUB_REPOSITORY"
monkeypatch.setenv("GITHUB_REPOSITORY", "TESTOWNER/TESTREPO")
mock_run.return_value.stdout.decode.return_value = (
"git@github.com:TESTOWNER/TESTREPO.git"
)

@deprecated(deadline=(2000, 1, 1))
def func_old():
pass

def test_deprecated_deadline_no_warn(self, monkeypatch):
"""Test cases where no warning should be raised."""
Expand Down

0 comments on commit bcc5001

Please sign in to comment.