Skip to content

Commit a8ccab5

Browse files
committed
Skip networkx if not installed
Signed-off-by: Edward Z. Yang <[email protected]>
1 parent 822fec4 commit a8ccab5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/test_pythonkey.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
"`--no-deps` to avoid overwriting the pytorch installation",
4242
UserWarning)
4343

44+
USE_NETWORKX = False
45+
try:
46+
import networkx # noqa: F401
47+
USE_NETWORKX = True
48+
except ImportError:
49+
warnings.warn("Some tests use networkx but it was not installed",
50+
UserWarning)
51+
4452
# NB: numpy is a testing dependency!
4553

4654

@@ -424,6 +432,7 @@ def create_new_arg(x):
424432

425433

426434
class TestPartitioning(TestCase):
435+
@unittest.skipIf(not USE_NETWORKX, "networkx not available")
427436
def test_recompute_partitioning(self):
428437
def fn(a, b):
429438
return torch.sin(torch.sin(a)) + b

0 commit comments

Comments
 (0)