-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from neptune-ai/wip/pj/fix-noop-backend
Fixes "neptune.init() throws exceptions with combination of ipython and offline-mode"
- Loading branch information
Showing
3 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,3 +111,7 @@ venv.bak/ | |
|
||
# Vim | ||
*.swp | ||
|
||
# VS Code | ||
.history | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# | ||
# Copyright (c) 2019, Neptune Labs Sp. z o.o. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import unittest | ||
|
||
from neptune.internal.backends.offline_backend import NoopObject | ||
|
||
class TestHostedNeptuneObject(unittest.TestCase): | ||
|
||
def test_builtin_fields_not_overriden(self): | ||
# given | ||
objectUnderTest = NoopObject() | ||
|
||
# then | ||
self.assertIsInstance(objectUnderTest.__class__, type) | ||
|
||
def test_attributes_fall_back_on_getattr(self): | ||
# given | ||
objectUnderTest = NoopObject() | ||
some_value = 42 | ||
|
||
# then | ||
self.assertEqual(objectUnderTest.foo, objectUnderTest) | ||
self.assertEqual(objectUnderTest.bar(some_value), objectUnderTest) | ||
|
||
def test_noop_object_callable(self): | ||
# given | ||
objectUnderTest = NoopObject() | ||
some_value = 42 | ||
|
||
# then | ||
self.assertEqual(objectUnderTest(some_value), objectUnderTest) | ||
|
||
def test_noop_object_context_manager(self): | ||
# given | ||
objectUnderTest = NoopObject() | ||
|
||
# when | ||
with objectUnderTest as e: | ||
|
||
# then | ||
e(42) |