diff --git a/mbuild/tests/test_protobuf.py b/mbuild/tests/test_protobuf.py index 42dfb6421..d0105bace 100644 --- a/mbuild/tests/test_protobuf.py +++ b/mbuild/tests/test_protobuf.py @@ -1,8 +1,11 @@ +import pytest from mbuild.tests.base_test import BaseTest from mbuild.formats.protobuf import write_pb2, read_pb2 +from mbuild.utils.io import has_protobuf class TestPB2(BaseTest): + @pytest.mark.skipif(not has_protobuf, reason="Protobuf package not installed") def test_loop(self, ethane): write_pb2(ethane, 'ethane.pb2') proto = read_pb2('ethane.pb2') diff --git a/mbuild/utils/io.py b/mbuild/utils/io.py index aa6963efd..53fb84c2c 100644 --- a/mbuild/utils/io.py +++ b/mbuild/utils/io.py @@ -222,6 +222,14 @@ def import_(module): except ImportError: has_py3Dmol = False +try: + from google import protobuf + has_protobuf = True + del protobuf +except ImportError: + has_protobuf = False + + def get_fn(name): """Get the full path to one of the reference files shipped for utils.