2021年12月22日 星期三

Git Submodule .gitmodules

 https://stackoverflow.com/questions/11358082/empty-git-submodule-folder-when-repo-cloned


.gitmodules

[submodule "external/common"]
path = external/common
url = ../common.git
[submodule "external/project"]
path = external/project
url = ../project.git
[submodule "external/tools"]
path = external/tools
url = ../tools.git

git submodule update --init


How to git add submodule with error "already exists in the index"?

https://stackoverflow.com/questions/12898278/issue-with-adding-common-code-as-git-submodule-already-exists-in-the-index



You need to remove your submodule git repository (projectfolder in this case) first for git path.

rm -rf projectfolder

git rm -r projectfolder

git submodule add <ssh/https> projectfolder


git submodule add git@gitlab.com:user/project.git external/project



Git submodule with branch

https://stackoverflow.com/questions/1777854/how-can-i-specify-a-branch-tag-when-adding-a-git-submodule

Existing answers have the second step missing and overloaded with details.

To switch an existing submodule to track a new remote url and/or a new branch:

  1. Edit the source of truth in .gitmodules.

For example, from

[submodule "api"]
    path = api
    url = https://github.com/<original_repo>/api.git

to

[submodule "api"]
    path = api
    url = https://github.com/<another_repo>/api.git
    branch = work-in-progress
  1. git submodule sync: Updates the description of submodules cached by git in .git/modules from the just-edited source of truth specified in .gitmodules.

  2. git submodule update --init --recursive --remote: Updates the checked-out submodules in the working copy.

  3. Commit the changes.


2021年12月17日 星期五

Python pytest set_exception_handler asyncio exception

 https://github.com/pytest-dev/pytest-asyncio/issues/205


New issue

set a default loop exception_handler that warns (similar to -p unraisablehook) #205

 Open
graingert opened this issue on Feb 23 · 1 comment

Comments

@graingert
Member

graingert commented on Feb 23

consider the following test:

import pytest
import asyncio

@pytest.mark.asyncio
async def test_foo():
    def raise_():
        raise Exception

    asyncio.get_running_loop().call_soon(raise_)
    await asyncio.sleep(0)

it passes cleanly.

However if you explicitly collect any errors:

import pytest
import asyncio

@pytest.mark.asyncio
async def test_foo():
    loop = asyncio.get_running_loop()
    old_exception_handler = loop.get_exception_handler()
    exceptions = []

    def exception_handler(*args, **kwargs):
        exceptions.append((args, kwargs))

    loop.set_exception_handler(exception_handler)
    try:
        def raise_():
            raise Exception

        asyncio.get_running_loop().call_soon(raise_)
        await asyncio.sleep(0)
        assert exceptions == []
    finally:
        loop.set_exception_handler(old_exception_handler)
=================================== test session starts ====================================
platform linux -- Python 3.9.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /home/graingert/projects/anyio, configfile: pyproject.toml
plugins: hypothesis-6.2.0, asyncio-0.14.0, anyio-2.1.0.post21+dirty
collected 1 item                                                                           

ham.py F                                                                             [100%]

========================================= FAILURES =========================================
_________________________________________ test_foo _________________________________________
ham.py:20: in test_foo
    assert exceptions == []
E   AssertionError: assert [((<_UnixSele...py:15'}), {})] == []
E     Left contains one more item: ((<_UnixSelectorEventLoop running=True closed=False debug=False>, {'exception': Exception(), 'handle': <Handle test_fo...y:15>, 'message': 'Exception in callback test_foo.<locals>.raise_() at /home/graingert/projects/anyio/ham.py:15'}), {})
E     Use -v to get the full diff
==================================== 1 failed in 0.04s ====================================
@HMaker

HMaker commented on Apr 5

I have a similar case, exceptions in background tasks pass silently. It would be good if background exceptions were checked at test end and re-raised there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
@graingert@HMaker

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...