This file contains hidden or 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
| use std::thread; | |
| use std::time::Duration; | |
| static mut SUM: i32 = 0; | |
| fn calculate(first: i32, second: i32) -> i32 { | |
| unsafe { | |
| SUM = first + second; | |
| } | |
| thread::sleep(Duration::from_secs(3)); |
This file contains hidden or 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
| #include <netdb.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <arpa/inet.h> | |
| #include <unistd.h> | |
| int main(int argc, char const *argv[]) |
This file contains hidden or 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
| @patch.object( | |
| UserController, "__init__", Mock(return_value=None) | |
| ) | |
| def test_get_second_picture(self): | |
| mock_app = MagicMock() | |
| mock_app.get_DB.return_value.all.return_value = ["Test 1", "Test 2"] | |
| user = UserController() | |
| user.picture = mock_app |
This file contains hidden or 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
| @patch.object( | |
| UserController, "__init__", Mock(return_value=None) | |
| ) | |
| def test_get_second_picture(self): | |
| mock_app = MagicMock() | |
| mock_app.get_DB.all.return_value = ["Test 1", "Test 2"] | |
| user = UserController() | |
| user.picture = mock_app |
This file contains hidden or 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
| class FakeDBAL: | |
| def all(self): | |
| print("all() method called") | |
| return ["Pic1", "Pic2", "Pic3"] | |
| class Picture: | |
| def __init__(self): | |
| print("__init__ method in the Picture class called") | |
| self.dbal = FakeDBAL() |
This file contains hidden or 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
| @patch.object( | |
| UserController, "__init__", Mock(return_value=None) | |
| ) | |
| def test_get_second_picture(self): | |
| mock_app = MagicMock() | |
| mock_app.dbal.all.return_value = ["Test 1", "Test 2"] | |
| user = UserController() | |
| user.picture = mock_app |
This file contains hidden or 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
| @patch.object( | |
| UserController, "__init__", Mock(return_value=None) | |
| ) | |
| def test_get_first_picture(self): | |
| mock_app = MagicMock() | |
| mock_app.dbal.all.return_value = ["Test 1", "Test 2"] | |
| user = UserController() | |
| user.picture = mock_app |
This file contains hidden or 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
| @patch.object( | |
| UserController, "__init__", Mock(return_value=None) | |
| ) | |
| def test_get_first_picture(self): | |
| user = UserController() | |
| user.picture = MagicMock() | |
| self.assertEqual("Test 1", user.get_first_picture()) |
This file contains hidden or 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
| import functools | |
| class Computer: | |
| @functools.singledispatchmethod | |
| def __init__(self, *parts): | |
| self.parts = " *** ".join(parts) | |
| def get_parts(self): | |
| return self.parts |
This file contains hidden or 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
| import functools | |
| class Computer: | |
| @functools.singledispatchmethod | |
| def __init__(self, *parts): | |
| self.parts = " *** ".join(parts) | |
| def get_parts(self): | |
| return self.parts |