Skip to content

Commit 23e5341

Browse files
committed
Merge branch 'refactor-test-application' into dev
2 parents 429f121 + 663dd32 commit 23e5341

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

tests/test_application.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ class TestApplicationForRefreshInBehaviors(unittest.TestCase):
331331
account = {"home_account_id": "{}.{}".format(uid, utid)}
332332
rt = "this is a rt"
333333
client_id = "my_app"
334-
app = ClientApplication(client_id, authority=authority_url)
334+
335+
@classmethod
336+
def setUpClass(cls): # Initialization at runtime, not interpret-time
337+
cls.app = ClientApplication(cls.client_id, authority=cls.authority_url)
335338

336339
def setUp(self):
337340
self.app.token_cache = self.cache = msal.SerializableTokenCache()
@@ -485,8 +488,10 @@ def mock_post(url, headers=None, *args, **kwargs):
485488

486489

487490
class TestTelemetryOnClientApplication(unittest.TestCase):
488-
app = ClientApplication(
489-
"client_id", authority="https://login.microsoftonline.com/common")
491+
@classmethod
492+
def setUpClass(cls): # Initialization at runtime, not interpret-time
493+
cls.app = ClientApplication(
494+
"client_id", authority="https://login.microsoftonline.com/common")
490495

491496
def test_acquire_token_by_auth_code_flow(self):
492497
at = "this is an access token"
@@ -509,8 +514,10 @@ def mock_post(url, headers=None, *args, **kwargs):
509514

510515

511516
class TestTelemetryOnPublicClientApplication(unittest.TestCase):
512-
app = PublicClientApplication(
513-
"client_id", authority="https://login.microsoftonline.com/common")
517+
@classmethod
518+
def setUpClass(cls): # Initialization at runtime, not interpret-time
519+
cls.app = PublicClientApplication(
520+
"client_id", authority="https://login.microsoftonline.com/common")
514521

515522
# For now, acquire_token_interactive() is verified by code review.
516523

@@ -534,9 +541,11 @@ def mock_post(url, headers=None, *args, **kwargs):
534541

535542

536543
class TestTelemetryOnConfidentialClientApplication(unittest.TestCase):
537-
app = ConfidentialClientApplication(
538-
"client_id", client_credential="secret",
539-
authority="https://login.microsoftonline.com/common")
544+
@classmethod
545+
def setUpClass(cls): # Initialization at runtime, not interpret-time
546+
cls.app = ConfidentialClientApplication(
547+
"client_id", client_credential="secret",
548+
authority="https://login.microsoftonline.com/common")
540549

541550
def test_acquire_token_for_client(self):
542551
at = "this is an access token"

0 commit comments

Comments
 (0)