---
# System prepended metadata

title: TIPS

---

# TIPS
---
## GIT

#### Crear tag en commit concreto en repositorio remoto:
```bash
git tag -a v{version} {commit}
git push origin v{version}
```

#### Eliminar tag de repositorio local
```bash
git tag -d v0.2.0
```

#### Eliminar tag de repositorio remoto
```bash
git push --delete origin v0.2.0
```
---


## Pytest/ Mock
#### Mock a class private method
```python
# base class
class Car:

    def __private():
        return "private"
        
    def no_private():
        return self.__private()

# Mock
@mock.patch.object(Car, “_Car__private”)
def test_mock_private(self, method):
    c = Car()
    c.no_private()
    method.assert_called_once() 
```

#### Pytest Monkey Patching
```python
def test_monkey_patch(monkeypatch):
    import os
    monkeypatch.setattr(os, "listdir", lambda: "Hola")
```

#### Mock `open()`
```python
with mock.patch("builtins.open", mock.mock_open(read_data="s=0.1\na=0.2")):
```