What I mean is, say two gentlemen were duelling over a woman. If they were to duel with swords, then the man with the greatest skill would win and so would be the rightful winner of the lady.
However, duelling with pistols doesn't seem to have this same test of skill and so seems rather more a game of luck to see who survives. How would it be a true test of who was the best man?
In short, you've sort of answered the question, but are just approaching with the wrong premise. The shift to pistols in the Anglo-centric dueling realms during the mid-18th century was in large part because they lacked the "same test of skill" and were "rather more a game of luck" (although partially by the decline of swords being a common item of dress as well). Dueling codes that developed in the late 18th century or early 19th century further reflected this by attempting to further equalize the exchange to eliminate whatever advantages a better marksman might have, by dictating a brief window in which to fire, discouraging aiming, and later on, mandating smoothbores even when rifled pistols began to proliferate. The duel wasn't really about deciding who was best, but rather, ideally, proving that both participants were men of honor, which was proven by their participation in the ritual.
The example you use of dueling over a lady isn't very accurate - even putting aside that the lady herself has agency and can choose whoever the hell she wants, and in the one duel that comes to mind of an actual argument over who should court a woman, she ended up with the loser tending his wounds - since that wouldn't be what the duel was over in most cases. If I was courting someone, and then she ends it to be courted by you instead, I might instigate an affair of honor against you over it, but it would be over the offense that you gave to me in ruining my relationship, not over the right to be in the relationship with her, and when concluded, we simply would have "proven" that we are both honorable gentlemen, not settled the actual courtship most likely (the woman, of course, might be influenced by the goings on, but she is under no obligation!).
I've written much more extensively about the duel here which should flesh out the underlying social impact of the duel, and a few other related topics here.
Do you have a period in mind? Pistols have evolved quite a lot over time.