Skip to content

Commit

Permalink
add has_protobuff variable (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
daico007 committed Jun 4, 2020
1 parent 4b60ced commit 2e00474
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mbuild/tests/test_protobuf.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
8 changes: 8 additions & 0 deletions mbuild/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2e00474

Please sign in to comment.