Skip to content

How to handle an optional package dependency in tests? #1710

@rimey

Description

@rimey

#1691 adds gcloud.monitoring for accessing the Google Monitoring API. The initial focus is on querying of metric data.

The primary way in which users will want to get metric data is as a pandas DataFrame, and the Query class offers an as_dataframe() method for this purpose.

However, pandas is a large package with dependencies on yet other packages. I would not recommend gcloud-python taking a dependency on it.

We have taken the approach of importing pandas dynamically in as_dataframe(). The documentation explains that use of this method requires that you have pandas installed. This works perfectly.

Tests are still an issue, however. The unit tests for as_dataframe() naturally require pandas, which is not currently present in the test environment.

How should we handle this?

Metadata

Metadata

Assignees

Labels

packagingtype: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions