Skip to content

Commit

Permalink
feat: add __str__ method to DatasetReference (#1477)
Browse files Browse the repository at this point in the history
* feat: add __str__ method to DatasetReference

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
Mattix23 and gcf-owl-bot[bot] authored Jan 30, 2023
1 parent 903dcdd commit f32df1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions google/cloud/bigquery/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ def __ne__(self, other):
def __hash__(self):
return hash(self._key())

def __str__(self):
return f"{self.project}.{self._dataset_id}"

def __repr__(self):
return "DatasetReference{}".format(self._key())

Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ def test___repr__(self):
expected = "DatasetReference('project1', 'dataset1')"
self.assertEqual(repr(dataset), expected)

def test___str__(self):
dataset = self._make_one("project1", "dataset1")
self.assertEqual(str(dataset), "project1.dataset1")


class TestDataset(unittest.TestCase):
from google.cloud.bigquery.dataset import DatasetReference
Expand Down

0 comments on commit f32df1f

Please sign in to comment.